DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 542BQ5kU3077667 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 542BQ5kU3077667 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=KGufK0Z5 X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 817D43858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1746185164; bh=Pgd2qDTuSwIxOX5oKUxO/UTQfkyxcIOFUt1pli1Db44=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KGufK0Z55HDPiOEqUg6TYCj+WyhsSvaEg+CX4csO/KWjW5TEFAEzd8EmKF9Tksnvb FXL8cLTGVrYzwwOEa7ZMljlg5uqsmRC4tPoqWw2abwjWGIx4xjm0TByIiWCQwyN7SB 6TWQNeUaJrZs/OVc5poyvYUdJ8lzydK9a1qffApQ= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 00F2A3858D20 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 00F2A3858D20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746185140; cv=none; b=F17aR0Q/X5i6P6o4a6XQJ0/x+3aM4ZRiPKbSYv2y8rssvoWmlhV5wtt8tPfiTfzlHnyoU9Lk9mGxmG7gkKoR2DIdzLKTC2M4GVxWFFir/PjlVAjXK2eejwUlkCOYYC9wtHd7cHioIfL0A5QGpkosicWlrpq1TaEiWIxsc5SAtnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1746185140; c=relaxed/simple; bh=PPm+65kusm1xQb6T/2bpbr0UUjcZVoHI6B8Eatu9nHY=; h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; b=Fto3gcbfbffaWO4KIOSVqaVRCJfYndaoAQxff7HVjL9wEGGen9jI2LfwuO5L/7zrADM0V8wbc+toTHMa2sJ815GlvdEjErpfv1OFkhv9V0VlotqJE9LuJMJa/qrc5VotaAIyDjYRRbI5OFfyML3cx1kk9XijVRXWSf0pDsolMEI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00F2A3858D20 Date: Fri, 2 May 2025 20:25:37 +0900 To: cygwin AT cygwin DOT com Subject: Re: Hang or crash after multiple SIGILL or SIGSEGV and siglongjmp Message-Id: <20250502202537.d63bec471cd28dec82675a0d@nifty.ne.jp> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 542BQ5kU3077667 On Tue, 25 Mar 2025 14:38:35 +0100 Christian Franke wrote: > Found because 'stress-ng --priv-instr ...' hangs and then requires > '/bin/kill --force ...': > > Testcase with >   [PATCH v2] Cygwin: signal: Copy context to alternate stack in the > SA_ONSTACK case > already applied: > > $ uname -r > 3.7.0-dev-16-g2ef1a37e7823-dirty.x86_64 > > $ cat loopsigill.c > #include > #include > #include > #include > > static volatile sig_atomic_t sigcnt; > static sigjmp_buf sjb; > > static void sighandler(int sig) > { >   (void)sig; >   ++sigcnt; >   siglongjmp(sjb, 1); >   write(1, "[FAIL]\n", 7); > } > > int main() > { >   signal(SIGILL, sighandler); >   printf("pid=%d\n", (int)getpid()); > >   while (sigsetjmp(sjb, 1)) >     ; > >   // loop: >   if (sigcnt < 10 || !(sigcnt % 1000)) >     printf("%06d\n", sigcnt); >   if (sigcnt >= 100000) >       return 42; >   asm volatile ("invd"); // goto loop; > >   return 13; // NOT REACHED > } > > $ gcc -o loopsigill loopsigill.c > > $ ./loopsigill # may succeed ... > pid=122 > 000000 > 000001 > ... > 099000 > 100000 > > $ echo $? > 42 > > $ ./loopsigill # ... or crash silently ... > pid=130 > 000000 > 000001 > ... > 026000 > 027000 > > $ echo $? > 0 > > $ ./loopsigill # ... or hang > pid=135 > 000000 > 000001 > ... > 037000 > 038000 > [requires '/bin/kill --force ...'] > > $ strace -o trace.log ./loopsigill # run '/bin/kill --force ...' ASAP! > pid=142 > 000000 > [always hangs after first signal and fills trace.log quickly] > > $ less trace.log > ... >    25   25501 [main] loopsigill 142 write: 7 = write(1, 0xA00017710, 7) > --- Process 6856 (pid: 142), exception c0000096 at 00000001004011b9 >   142   25643 [main] loopsigill 142 exception::handle: In > cygwin_except_handler exception 0xC0000096 at 0x1004011B9 sp 0x7FFFFCBE0 >    26   25669 [main] loopsigill 142 exception::handle: In > cygwin_except_handler signal 4 at 0x1004011B9 >    38   25707 [main] loopsigill 142 break_here: break here > --- Process 6856 (pid: 142), exception c0000096 at 00000001004011b9 > --- Process 6856 (pid: 142), exception c0000096 at 00000001004011b9 > ... likely repeated until disk is full or time_t wraps around... > --- Process 6856 (pid: 142), exception c0000096 at 00000001004011b9 > > > Problem also occurs > - without the mentioned patch, > - with get/setcontext() instead of sig*jmp(), > - with nullptr access and SIGSEGV handler, > - with Cygwin 3.5.7-1. > > I agree that this is not a common use case :-) Thanks for the report. I'm sorry for keeping you waiting so long. I finally could fix the issue. I'll push the patch shortly. -- Takashi Yano -- 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