DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54U959JL1015509 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 54U959JL1015509 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=NkIB1BPI X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A642385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1748595908; bh=q1h/aNlOycQRcNiFukq3KVTfPCjw4QVb77tpo83gG2w=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=NkIB1BPIjBwMMZxlTCKjVe0Pbkss1Ib8bQx7oyiVolV4PH1qTi0IvVfYFNqreBos1 CB0LaB60U/W53gXU84eYyww4NeBwieT9YvYO93RD1QbgN4585Mc5LfL6j3WQljQGOx EHS17/w5FOCyYWvLFQwrvJox1TpgtXIQpQeIZq4I= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9A113858D39 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9A113858D39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748595848; cv=none; b=PUD4kBbOw02gef6gx3t3cDHQX0dp5joMLRDujXYpnccKYqt9MaxadC36dArxyvfeOAqb8x8Gpzru0dgM0N2QBYs5R52bndz5rtJhq9NESF+t2PdJuilPk4G9QFIUPktmNRdan8palnaVhjxRRedL0MrCvecoMamt7/COLWERvXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748595848; c=relaxed/simple; bh=/9wWAcvS7X8/alij7zrpO3XMumkWxUOK4w7Y6pOA5oc=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=ajwiFVIWuxeIIhqUMN0nM3hQqXXUxBzOAYW7LAB3S85BsOQufPL6D0ZBGod//osoPdI75Wx9jfrhzrqgqop4+I1kRkEhr2XDl5dYUj5VuzkYMfAdXTaqaK41ZWlGGw5z5ipiEuVn1QNAqOQIbiT+Z6stEkJGyasxpikS8bqFVyY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9A113858D39 Subject: Re: Crash or hang if SIGSEGV+SIGALRM are nested To: cygwin AT cygwin DOT com References: <20250528215707 DOT ddb72fb28122c3ed07da8c5b AT nifty DOT ne DOT jp> <20250529102846 DOT 8144f502c3f17decbe6700c1 AT nifty DOT ne DOT jp> <76940263-49e8-1b4a-17f2-11f5545014ab AT t-online DOT de> <20250530015410 DOT e8c4808c7947682b3309fbe7 AT nifty DOT ne DOT jp> <32cf9316-3e97-7fab-f975-851c3dfc25b9 AT t-online DOT de> <20250530174730 DOT 7475a800c9f189b21ee0646e AT nifty DOT ne DOT jp> Message-ID: <29f9a32f-62bb-3540-ae3c-f58afe4148b5@t-online.de> Date: Fri, 30 May 2025 11:04:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 SeaMonkey/2.53.20 MIME-Version: 1.0 In-Reply-To: <20250530174730.7475a800c9f189b21ee0646e@nifty.ne.jp> X-TOI-EXPURGATEID: 150726::1748595844-E4FF6965-ADCAB464/0/0 CLEAN NORMAL X-TOI-MSGID: a3205b13-101a-4b17-9783-0e570fe6bfdd 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: Christian Franke via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Christian Franke Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Takashi Yano via Cygwin wrote: > On Thu, 29 May 2025 20:01:31 +0200 > Christian Franke wrote: >> Takashi Yano via Cygwin wrote: >>> On Thu, 29 May 2025 17:32:19 +0200 >>> Christian Franke wrote: >>> ... >>>> I still don't fully understand why a SIGSEGV triggered by an instruction >>>> could interrupt a SIGALRM handler. >>>> https://sourceware.org/pipermail/cygwin/2025-May/258145.html >>>> >>>> I guess such behavior is valid from the POSIX point of view, but it is >>>> at least unexpected. If the SIGALRM handler is already running, it >>>> should have interrupted the thread such that the instruction triggering >>>> the segfault is not executed until the SIGALRM handler returns. >>> I try to explain what is happing using the figure below. >>> >>> <<<<<< Main thread >>>>>> < Signal Thread > >>> SIGNAL >>> main() handler1() handler2() QUEUE wait_sig() >>> | . . | | >>> | . . ALRM | | >>> +----------------------------------------->| ALRM | >>> | . . SEGV +--------->| >>> X----------------------------------------->| | >>> | . arm ALRM | | >>> +----------+ <----------------------------------------+ >>> | . | SEGV | >>> | . +--------->| >>> | . | | >>> | . arm SEGV | | >>> +----------+ <-----------------------------+ >>> . | | | >>> longjmp() | | | >>> +---------------------+ | | >>> | . . | | >>> | . . | | >>> >>> The point is the exception handler does not arm SIGSEGV handler >>> directly. It just pushes the SIGSEGV into the signal queue. >>> The signal thread reads the queue and process it asynchronously, >>> and arms the handler(). >>> >> I see. Thanks for nice explanation! >> >> I created an issue at stress-ng upstream because at least the --mprotect >> test is affected: >> https://github.com/ColinIanKing/stress-ng/issues/529 > Thanks! > > BTW, do you think this is the right thing? > https://github.com/RISCV-Tools/stress-ng/commit/bf24393357cde137bb8e7b38f917f565946199fd > > I think the patch should set SIGSEGV mask on SIGALRM. Indeed, I missed that, thanks! Reopen of the issue requested. -- Regards, Christian -- 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