DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 4AECv4nV833848 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 4AECv4nV833848 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=sciTzm1n X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70C2E3858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1731589022; bh=dAfjUbHpanLqWrHJUsIqrMAsuadK7kZudRtmHr573IU=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=sciTzm1nPAji0C1Bkuevl+S9i7x4cp9/E4rNtfpZEm4i+XcHeO1m6N/lV+R5+WlMx Pr93bow2R9tNT5O/huTsnpv3yDqKF1UALoyacQCfdGiCRLI6zhTg4kjC6ZoD5D19rj +BWMNmdeVmVtwrp0Bl3OBCA6SM3FMsrux1hsz9KQ= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38F6B3858D28 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 38F6B3858D28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731588947; cv=none; b=QzC55o/a/rZWgfD5LrHjglMPFZfEtV+puQYZ3YPsrHzGTkzLC5wJmp6UZYOBgVHYJKUtLAwtwCjfLeqU64W6jV9dVhXIghP+1N8/sR/44mqIxR5hqeJRQKCOJpdW6mrTCqCJw/wHxG/Ez1OxRNi1zAqSoo7XnPkA2ttreAUVsgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1731588947; c=relaxed/simple; bh=sFFoofI/5agPYT2Oi86NcgER1xAiS6n9HxnefYA+d+4=; h=From:Subject:To:Message-ID:Date:MIME-Version; b=j03j/SZjZP09Pd03lKLVivR09mHVlc1XwGXByCH90MUOTNP1DhIWvmZ3INpsuQMdRrxyzigaDsvCdcOhbSzZf5HlJ3Xndm2AotONxgVzP9h0I2iNXP0Q4LjFrD1kl94BMxzsk3Fwtv0ZEZtJZIJP8m+uHclIg9vbQvYSrmGefHk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38F6B3858D28 Subject: Segfault in pthread_sigqueue() or sigtimewait() To: cygwin AT cygwin DOT com Message-ID: Date: Thu, 14 Nov 2024 13:55:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.18.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1493F554F59B5FD8B877C5F5" X-TOI-EXPURGATEID: 150726::1731588939-9DFEA90D-CBCA4264/0/0 CLEAN NORMAL X-TOI-MSGID: 70bb0451-2f37-46e3-8896-f0342c9a33f4 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Christian Franke via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Christian Franke Sender: "Cygwin" This is a multi-part message in MIME format. --------------1493F554F59B5FD8B877C5F5 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit After enabling the usage of pthread_sigqueue() in stress-ng, 'stress-ng --pthread ...' occasionally reports that child processes failed with SIGSEGV. The problem is unrelated to the recent fix of the signature of pthread_sigqueue(): https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=1e8c92e It could be reproduced with Cygwin 3.5.4-1 and with current 3.6.0 TEST release if the signature is adjusted. Testcase (attached): $ gcc -O2 -o sigfault sigfault.c # Add -DBETA if compiling for a TEST release $ strace -o trace.log ./sigfault pthread_create({0xa000188d0}, ...)=0 pthread_sigqueue(0xa000188d0, SIGUSR1, .) sigtimedwait(...)=30 (errno=0) ... sigtimedwait(...)=30 (errno=0) pthread_sigqueue(0xa000188d0, SIGUSR1, .)=0 pthread_join(0xa000188d0, .)=0 pthread_create({0xa000188d0}, ...)=0 pthread_sigqueue(0xa000188d0, SIGUSR1, .) sigtimedwait(...)=30 (errno=0) pthread_sigqueue(0xa000188d0, SIGUSR1, .)=0 pthread_join(0xa000188d0, .)=0 pthread_create({0xa000188d0}, ...)=0 pthread_sigqueue(0xa000188d0, SIGUSR1, .) Segmentation fault $ cat trace.log ...    78  103937 [main] sigfault 2074 sig_send: Waiting for pack.wakeup 0x21C    80  104017 [sig] sigfault 2074 sigpacket::process: signal 30 processing   147  104164 [sigfault] sigfault 2074 __set_errno: int sigwait_common(const sigset_t*, siginfo_t*, PLARGE_INTEGER):643 setting errno 11   103  104267 [sig] sigfault 2074 sigpacket::process: signal 30, signal handler 0x1    84  104351 [sigfault] sigfault 2074 sigwait_common: returning signal -1    81  104432 [sig] sigfault 2074 sigpacket::setup_handler: controlled interrupt. stackptr 0x7FFDFE220, stack 0x7FFDFE218, stackptr[-1] 0x100401109    78  104510 [sig] sigfault 2074 proc_subproc: args: 4, 1    74  104584 [sig] sigfault 2074 proc_subproc: clear waiting threads    71  104655 [sig] sigfault 2074 proc_subproc: finished clearing    70  104725 [sig] sigfault 2074 proc_subproc: returning 1   125  104850 [sig] sigfault 2074 _cygtls::interrupt_setup: armed signal_arrived 0x24C, signal 30    74  104924 [sig] sigfault 2074 sigpacket::setup_handler: signal 30 delivered    83  105007 [sigfault] sigfault 2074 set_process_mask_delta: oldmask 0, newmask 20000000, deltamask 20000000 --- Process 9568 (pid: 2074), exception c0000005 at 0000000000000001    80  105087 [sig] sigfault 2074 sigpacket::process: returning 1 --- Process 9568 (pid: 2074) thread 7320 exited with status 0xc0000005 --- Process 9568 (pid: 2074) thread 8928 exited with status 0xc0000005 --- Process 9568 (pid: 2074) thread 6792 exited with status 0xc0000005 --- Process 9568 (pid: 2074) thread 5020 exited with status 0xc0000005 --- Process 9568 thread 9020 exited with status 0xc0000005 --- Process 9568 exited with status 0xc0000005 I guess the problem occurs because pthread_sigqueue() is sometimes issued after the thread function already returned. The thread pointer should be valid until pthread_join() is called. Sorry if I missed something. -- Regards, Christian --------------1493F554F59B5FD8B877C5F5 Content-Type: text/plain; charset=UTF-8; name="sigfault.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="sigfault.c" I2RlZmluZSBfR05VX1NPVVJDRQ0KI2luY2x1ZGUgPGVycm5vLmg+DQojaW5jbHVkZSA8cHRo cmVhZC5oPg0KI2luY2x1ZGUgPHN0ZGlvLmg+DQoNCnN0YXRpYyB2b2xhdGlsZSBjaGFyIHN0 YXJ0ZWQsIHN0b3A7DQoNCnN0YXRpYyB2b2lkICogdGhyZWFkZnVuYyh2b2lkICphcmcpDQp7 DQogICh2b2lkKWFyZzsNCg0KICBzdGFydGVkID0gMTsNCiAgd2hpbGUgKCFzdG9wKQ0KICAg IHNjaGVkX3lpZWxkKCk7DQoNCiAgc2lnaW5mb190IGluZm8gPSB7MH07DQogIHNpZ3NldF90 IG1hc2s7IHNpZ2VtcHR5c2V0KCZtYXNrKTsNCiAgc2lnYWRkc2V0KCZtYXNrLCBTSUdVU1Ix KTsNCiAgc3RydWN0IHRpbWVzcGVjIHRpbWVvdXQ7DQogIHRpbWVvdXQudHZfc2VjID0gMDsg dGltZW91dC50dl9uc2VjID0gMTAwMDsNCg0KICBlcnJubyA9IDA7DQogIGludCByZXQgPSBz aWd0aW1lZHdhaXQoJm1hc2ssICZpbmZvLCAmdGltZW91dCk7DQogIHByaW50Zigic2lndGlt ZWR3YWl0KC4uLik9JWQgKGVycm5vPSVkKVxuIiwgcmV0LCBlcnJubyk7IGZmbHVzaChzdGRv dXQpOw0KDQogIHJldHVybiBOVUxMOw0KfQ0KDQppbnQgbWFpbigpDQp7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0dXJuIDE7DQogIH0NCg0KICBw cmludGYoImRvbmVcbiIpOw0KICByZXR1cm4gMDsNCn0NCg== --------------1493F554F59B5FD8B877C5F5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple --------------1493F554F59B5FD8B877C5F5--