www.delorie.com/archives/browse.cgi | search |
DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 52AA0oV32656533 |
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 52AA0oV32656533 |
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=FEnkhcLF | |
X-Recipient: | archive-cygwin AT delorie DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 5B0FA3858D21 |
DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
s=default; t=1741600847; | |
bh=Nqvk4zofX61SZzqZ5CFkCf2fZyZ4yblRBOVAy+Lfxyg=; | |
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: | |
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: | |
From; | |
b=FEnkhcLFcDm2SSUsvak/IUH9GtyCn6KmzdPJBlRODCjOK8HDCy1iA3k1W+lp6dIdM | |
All3K/7dMhKIV0CS46OG5tmVf1eSpRgHh7h3eU3TQXLo+jy8j36gzKlp4q7Asx8YZA | |
k4rReSq1G6HBFhcXIXcKG8YX+fluO9xMokUfPTp0= | |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 515733858D20 |
Date: | Mon, 10 Mar 2025 11:00:20 +0100 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: cygwin 3.6.0: No signals received after swapcontext() is used |
Message-ID: | <Z864NNIyYwOWk5I3@calimero.vinschen.de> |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <ec6e2050-953f-0d47-c385-cfa598566291 AT t-online DOT de> |
<Z8nxYCxthcsMVqzL AT calimero DOT vinschen DOT de> | |
<bf4eb7e1-66e3-e1f9-67e2-c4d4a75ff6c8 AT t-online DOT de> | |
MIME-Version: | 1.0 |
In-Reply-To: | <bf4eb7e1-66e3-e1f9-67e2-c4d4a75ff6c8@t-online.de> |
X-BeenThere: | cygwin AT cygwin DOT com |
X-Mailman-Version: | 2.1.30 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
From: | Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com> |
Reply-To: | cygwin AT cygwin DOT com |
Cc: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
Errors-To: | cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com |
Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
X-MIME-Autoconverted: | from base64 to 8bit by delorie.com id 52AA0oV32656533 |
On Mar 8 12:07, Christian Franke via Cygwin wrote: > Corinna Vinschen via Cygwin wrote: > > On Mar 6 13:24, Christian Franke via Cygwin wrote: > > > Found because 'stress-ng --context 1 ...' always hangs. > > > > > > The attached testcase uses the example from Linux swapcontext(3) to call the > > > context functions. > > Just tested with 3.5.3 and it doesn't work there, either. > > > > So yeah, it's a bug, but it's not a 3.6 regression and of minor > > importance. We can look into that for 3.7. > > > > This is possibly a regression introduced in 3.0.6. A comparison of strace > outputs of signal handling before and after the swapcontext() calls reveals > that 'incyg' is incorrectly set after swapcontext(). A revert of > Â https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=c5f9eed1 > fixes both the testcase and 'stress-ng --context ...'. Ahhh, good point. When I looked into get/setcontext last week, I was wondering about this _my_tls.incyg = true, but didn't look into the history. I'm not sure if this was the right thing to do anyway. Unfortunately, my commit message of the time was really really bad, and I don't see anything in the mailing lists pointing out where the idea to set iscyg was coming from. In the light of the signal changes in Cygwin, it might be a good idea to drop it. > No patch provided because I'm not sure how to handle the (at least) two > other use cases of setcontext() correctly: > - the call from _cygtls::call_signal_handler(), and I re-read the POSIX and Linux man pages on sigaction. None of them claim that the context given to the signal handler is anything other than read-only information given to the handler, and, worse, supposed to be used by the signal mechanism after the signal handler returns. So it seems calling setcontext() on the vague notion that the signal handler expects this if it changed the context, was a bug from the start. I'm inclined to apply this patch: diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 6d8985374b9e..a05883e3fc4f 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1850,14 +1850,6 @@ _cygtls::call_signal_handler () ? context.uc_sigmask : this_oldmask); if (this_errno >= 0) set_errno (this_errno); - if (this_sa_flags & SA_SIGINFO) - { - /* If more than just the sigmask in the context has been changed by - the signal handler, call setcontext. */ - context_copy.uc_sigmask = context.uc_sigmask; - if (memcmp (&context, &context_copy, sizeof context) != 0) - setcontext (&context); - } } /* FIXME: Since 2011 this return statement always returned 1 (meaning @@ -1899,7 +1891,6 @@ setcontext (const ucontext_t *ucp) { PCONTEXT ctx = (PCONTEXT) &ucp->uc_mcontext; set_signal_mask (_my_tls.sigmask, ucp->uc_sigmask); - _my_tls.incyg = true; RtlRestoreContext (ctx, NULL); /* If we got here, something was wrong. */ set_errno (EINVAL); It's not quite clear to me why signal handling should be broken if setcontext is used inside a signal handler. The incyg flag is false when running the signal handler and that's correct. Theoretically a running signal handler is not different from other process code. Do you have an STC, by any chance? Thanks, Corinna -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |