| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:to:from:subject:message-id:date:mime-version | |
| :content-type; q=dns; s=default; b=xHATrQOqiOWH8JkbHat6A2MbgLZ0L | |
| IYKyRxREmICcqZDJtPPLPfkb9AMHURmDfoe45oUtjZP1I0nyQNNK8glRxGYXE/9a | |
| HEmJB3LOUThUR7Tn3rNY552GkxDas1hrbG+I14lKrnbVYdeooS0KSrNUqFPmO5oq | |
| uqUcnpprCTdlSU= | |
| DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
| :list-unsubscribe:list-subscribe:list-archive:list-post | |
| :list-help:sender:to:from:subject:message-id:date:mime-version | |
| :content-type; s=default; bh=yjxqcH5BdCF4Z9FkjGU+pzuKlM0=; b=x41 | |
| HhwhDIUpwAdJuNkLJVfv9XD0p1s5ZeAwCHZ/KJ9yBnclTZhXWBXzmd06qvZlZi0O | |
| ISy6LTjxr+UF3i0NT61x7ghUkS23WQTzaL4UA45qVsPIbqc0Hj1X40PSwU9b3HnZ | |
| nnze1z8nkeSqcD/VKYtuhBRyO48Io6DYaZOtfuv8= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Authentication-Results: | sourceware.org; auth=none |
| X-Virus-Found: | No |
| X-Spam-SWARE-Status: | No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,SPF_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=set-up, 2.10 |
| X-HELO: | mail-wm0-f46.google.com |
| X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:openpgp:autocrypt :message-id:date:user-agent:mime-version; bh=Exzzql9TZZ+yOqYuwfbe6zIPnB7Eo9OF+6qL/EUdxNs=; b=LSvV/Ur0DZrbnP40jCG1EbTHEIU6BmCi1n7CT8uNZGrXQApyatq75twPGnZ7cYH8yq 1q85KezzBS1comZnJY7lL1TYk5agn9uQwg4ira3fpZOKXtN5+xc1T+fpzl4Mz3rm/6Mh +8jv/o07nZTGEO51lgHXB8XjqjtuPHq48PhOEQv6JDplYPPrXsw3XwSZQi6tqIQVkHmt GPRqw4Km/xGEFy0n5XQGdZfD/4SQCdzeowUzbwJ+7A6mxm4fjYjNgaGOdPIvZ8CL4SxU JjAHuV97+AGrqWZ8nz2SmZVGcykzzb+1jVNZ6piC8YCmO5icRuBcVecTwSt0tyhbJHy4 Jv1w== |
| X-Gm-Message-State: | ALQs6tATpx/DaS5cgfDHwx+Ks+1mUxDE8Fj2eWhkgXusITrN7n7zmQyW 5wN6Rd+yleVZhKs6LWXaBCVlFg== |
| X-Google-Smtp-Source: | AIpwx4/F9psJFiYJHps2M4gYKtiXfTq2ZOdwniI7Kl6CG1AIbcTc5huI4lfB/ZSJih3uORf7tcDl2g== |
| X-Received: | by 10.80.181.85 with SMTP id z21mr43109720edd.223.1524729487534; Thu, 26 Apr 2018 00:58:07 -0700 (PDT) |
| To: | cygwin AT cygwin DOT com |
| From: | Thomas Zimmermann <tdz AT users DOT sourceforge DOT net> |
| Subject: | Bug: Synchronous signals broken on Cygwin 64 |
| Openpgp: | preference=signencrypt |
| Autocrypt: | addr=tdz AT users DOT sourceforge D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e1pcXfiOuZLMJ5OTga6GxWimmP7rrWKTIlP x57wXD+v6c4A4VYW973YXNh1mVXwON3ydMJGBBgRAgAGBQJEPBcxAAoJENna19RO8d8IASEA niQqMp4Yd00/t47D09opsugE9GBHAJ9sJZgtyq9lLB3xCFm16nooejR/XA== |
| Message-ID: | <bc993d03-a9ac-d1c9-c33a-03cfc810edbe@users.sourceforge.net> |
| Date: | Thu, 26 Apr 2018 09:57:59 +0200 |
| User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
| MIME-Version: | 1.0 |
| X-IsSubscribed: | yes |
--lFbo5slULApREF5dDJHaWmp8CmioOLeRi
Content-Type: multipart/mixed; boundary="wtxaMxR8iwSUN3mw6nddWiunoTLQjB9QC";
protected-headers="v1"
From: Thomas Zimmermann <tdz AT users DOT sourceforge DOT net>
To: cygwin AT cygwin DOT com
Message-ID: <bc993d03-a9ac-d1c9-c33a-03cfc810edbe AT users DOT sourceforge DOT net>
Subject: Bug: Synchronous signals broken on Cygwin 64
--wtxaMxR8iwSUN3mw6nddWiunoTLQjB9QC
Content-Type: multipart/mixed;
boundary="------------2835FB10DBC0098E1855BDF8"
Content-Language: en-US
This is a multi-part message in MIME format.
--------------2835FB10DBC0098E1855BDF8
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hello mailing list,
I noticed that synchronous signals (e.g., SIGSEGV, SIGFPE) appear to be
broken on 64-bit Cygwin systems. I could not find additional information
on the mailing list. If this is not already a known problem, you'll find
some analysis below.
I use Cygwin DLL 2.10 with all packages up-to-date. My test system runs
Windows 7.
The expected behavior is that an installed signal handler runs exactly
once for a signal and the OS terminates the program if the handler
returns. This works on 32-bit Cygwin. From my observation, Cygwin 64
differs in the follow ways:
1) Generating a synchronous signal on the main thread, makes the signal
handler enter an endless loop. The attached test 'syncsig.c' illustrates
this.
2) Generating a synchronous signal on an additional POSIX thread ignores
the installed signal handler entirely. The handler does not run and the
program gets terminated immediately. The attached test 'syncsig_mt.c'
illustrates this.
As mentioned, both cases work correctly on 32-bit installations. I
cannot point to the exact location of the problem, but it appears that
the Cygwin exception-handler code is not set up by 64-bit code.
In case 2) I can see the Windows function KiUserExceptionDispatcher()
being executed for the synchronous signal on the affected thread. This
should lead to a call to the Cygwin exception handler. It does for
32-bit, but not for 64-bit code.
=46rom what I've seen, the exception handler is installed in the c'tor
exception::exception(). [exception.cc:138] The only invocation I found
was in SetThreadName(). [miscfuncs.cc:951] This set-up code is 32-bit-only.
BTW, is there a bug tracker for Cygwin? I'd open a bug report there, or
add the information to an existing one.
Best regards
Thomas
[exception.cc:138]
https://cygwin.com/git/gitweb.cgi?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dwinsup=
/cygwin/exception.h;h=3Dffff7464ba11b5526fcf9d13e32334912a30a3b0;hb=3D4c73a=
d6b20378e4b74355fcdb2005f2aac489c9f#l138
[miscfuncs.cc:951]
https://cygwin.com/git/gitweb.cgi?p=3Dnewlib-cygwin.git;a=3Dblob;f=3Dwinsup=
/cygwin/miscfuncs.cc;h=3D3ad658739ad9e85868ca74ce2e86aa6ddbdbfb37;hb=3D4c73=
ad6b20378e4b74355fcdb2005f2aac489c9f#l951
--=20
Implement thread-safe and fault-tolerant software in C: visit picotm.org
--
GnuPG: http://tdz.users.sourceforge.net/tdz.asc
Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08
Website: transactionblog.org
--------------2835FB10DBC0098E1855BDF8
Content-Type: text/x-csrc;
name="syncsig.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="syncsig.c"
/*
* This test program works on 32-bit and 64-bit Cygwin. On 32-bit=20
* systems, the signal handler runs *exactly* once, which is the correct
* behaviour. On 64-bit systems, the exception code enters an endless=20
* loop and the signal handler runs over and over.
*
* Compile with
*
* gcc -Wall -O0 -osyncsig ./syncsig.c
*
* Run with
*
* ./syncsig
*
* Expected Result
*
* Program prints "signal handler running" once
*
* Actual Result
*
* On 64-bit systems, the handler runs in an endless loop
* */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
static void
signal_handler(int signum, siginfo_t* info, void* ucontext)
{
fprintf(stderr, "signal handler running\n"); // unsafe in real code!
}
int
main(int argc, char* argv[])
{
struct sigaction act =3D {
.sa_sigaction =3D signal_handler,
.sa_flags =3D SA_SIGINFO,
};
sigemptyset(&act.sa_mask);
sigaction(SIGFPE, &act, NULL);
/* Trigger Windows Exception for division by zero */
argc /=3D !argc;
fprintf(stderr, "no exception generated\n");
return EXIT_SUCCESS;
}
--------------2835FB10DBC0098E1855BDF8
Content-Type: text/x-csrc;
name="syncsig_mt.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="syncsig_mt.c"
/*
* This test program works on 32-bit Cygwin, but fails on 64-bit systems.
* Running a signal handler for SIGFPE on the created POSIX thread does
* not work.
*
* Compile with
*
* gcc -Wall -O0 -pthread -osyncsig_mt ./syncsig_mt.c
*
* Run with
*
* ./syncsig_mt
*
* Expected Result
*
* Program prints "signal handler running"
*
* Actual Result
*
* No output on 64-bit systems, signal handler does not run
* */
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
static void
signal_handler(int signum, siginfo_t* info, void* ucontext)
{
fprintf(stderr, "signal handler running\n"); // unsafe in real code!
}
static void*
thread_start(void* arg)
{
int argc =3D *(int*)arg;
/* Trigger Windows Exception for division by zero */
argc /=3D !argc;
fprintf(stderr, "no exception generated\n");
return NULL;
}
int
main(int argc, char* argv[])
{
struct sigaction act =3D {
.sa_sigaction =3D signal_handler,
.sa_flags =3D SA_SIGINFO,
};
sigemptyset(&act.sa_mask);
sigaction(SIGFPE, &act, NULL);
pthread_t thread;
pthread_create(&thread, NULL, thread_start, &argc);
pthread_join(thread, NULL);
return EXIT_SUCCESS;
}
--------------2835FB10DBC0098E1855BDF8--
--wtxaMxR8iwSUN3mw6nddWiunoTLQjB9QC--
--lFbo5slULApREF5dDJHaWmp8CmioOLeRi
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
iF0EARECAB0WIQQW//WZgvjlqhjGUiDZ2tfUTvHfCAUCWuGGhwAKCRDZ2tfUTvHf
CEnhAJ9wLkhD26VXiy8Bn9RD+gDFC2l6TgCfcvzQdlj1X4exFpdCJNoom9eNINI=
=JJyM
-----END PGP SIGNATURE-----
--lFbo5slULApREF5dDJHaWmp8CmioOLeRi--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |