From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 21 12:39:09 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8C6A4D6C for ; Thu, 21 Nov 2013 12:39:09 +0000 (UTC) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com [IPv6:2a00:1450:4010:c03::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1C664248B for ; Thu, 21 Nov 2013 12:39:08 +0000 (UTC) Received: by mail-la0-f41.google.com with SMTP id eo20so2371763lab.14 for ; Thu, 21 Nov 2013 04:39:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=K4FL/i/vxeWzjvXlndKh+r4XivLxwROw8fuJeC1VQek=; b=ZMNZYpNWrPS8vttBedCX/xxSGqkmqhQf4+TdHO2RfGmofnpsB5sTekDIVkm2nIjLen fx/6h/YJVgffFG/L2olwSSzsFAo/t0+e3mAaBkIr6DteHHtoOmZajlNc5bb7MdyN3TZo 5wAFu3ubTepyDt0j8STvk23TifwZy0lTQw/6IzYNH8faGcFuTRBdKOkelMWxSxRnf7Bs W6eedLotQdz2mIlbhvrKNDpXd6e4GIpDbtIptqebuLRi1XJ45U3xc2SBPO4/YV6U4Oit CXO/cb+EYUEOCigHNY7BX2sYBxSIdcs3/EKp9nGGzqSB6y0KlDr47NSc9nzxjYwh2O+q ee+A== X-Received: by 10.152.170.199 with SMTP id ao7mr1130074lac.40.1385037546278; Thu, 21 Nov 2013 04:39:06 -0800 (PST) Received: from [172.16.0.2] (tx97.net. [85.198.160.156]) by mx.google.com with ESMTPSA id 8sm32490258laq.5.2013.11.21.04.39.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Nov 2013 04:39:05 -0800 (PST) Message-ID: <528DFEE6.6020504@gmail.com> Date: Thu, 21 Nov 2013 14:39:02 +0200 From: Vitaly Magerya User-Agent: Thunderbird MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: Problem with signal 0 being delivered to SIGUSR1 handler Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Nov 2013 12:39:09 -0000 Hi, folks. I'm investigating a test case failure that devel/boehm-gc has on recent FreeBSD releases. The problem is that a signal handler registered for SIGUSR1 is sometimes called with signum=0, which should not be possible under any conditions. Here's a simple test case that demonstrates this behavior: /* Compile with 'c99 -o example example.c -pthread' */ #include #include #include #include void signal_handler(int signum, siginfo_t *si, void *context) { if (signum != SIGUSR1) { printf("bad signal, signum=%d\n", signum); exit(1); } } void *thread_func(void *arg) { return arg; } int main(void) { struct sigaction sa = { 0 }; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = signal_handler; if (sigfillset(&sa.sa_mask) != 0) abort(); if (sigaction(SIGUSR1, &sa, NULL) != 0) abort(); for (int i = 0; i < 10000; i++) { pthread_t t; pthread_create(&t, NULL, thread_func, NULL); pthread_kill(t, SIGUSR1); } return 0; } Under FreeBSD 9.2-RELEASE amd64 I pretty consistently get "signum=0" from this program, but you may need to run it a few times or increase the number of iterations to see the same. Interestingly enough, I don't see this behavior under 9.0-RELEASE. So, any ideas what the problem here is?