From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72881 invoked by alias); 26 Jun 2015 14:14:41 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 72868 invoked by uid 89); 26 Jun 2015 14:14:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: calimero.vinschen.de Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jun 2015 14:14:39 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 16FCEA80853; Fri, 26 Jun 2015 16:14:37 +0200 (CEST) Date: Fri, 26 Jun 2015 14:14:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: [ANNOUNCEMENT] TEST RELEASE: Cygwin 2.1.0-0.1 Message-ID: <20150626141437.GV31223@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <558706D5.1020508@cornell.edu> <20150622110835.GE28301@calimero.vinschen.de> <20150626111249.GS31223@calimero.vinschen.de> <558D3F4C.6090207@cornell.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FiqEyLLt06qkB6ow" Content-Disposition: inline In-Reply-To: <558D3F4C.6090207@cornell.edu> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-06/txt/msg00374.txt.bz2 --FiqEyLLt06qkB6ow Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3623 Hi Ken, On Jun 26 08:02, Ken Brown wrote: > On 6/26/2015 7:12 AM, Corinna Vinschen wrote: > >On Jun 22 13:08, Corinna Vinschen wrote: > >>On Jun 21 14:47, Ken Brown wrote: > >>>On 6/20/2015 4:55 PM, Corinna Vinschen wrote: > >>>>- First cut of an implementation to allow signal handlers running on = an > >>>> alternate signal stack. > >>>> > >>>>- New API sigaltstack, plus definitions for SA_ONSTACK, SS_ONSTACK, S= S_DISABLE, > >>>> MINSIGSTKSZ, SIGSTKSZ. > >>>[...] > >>[...] > >did you have a chance to test this a bit, in the meantime? >=20 > Yes, but I don't have anything definitive to report yet. I tried to test= a > facility in emacs that uses the alternate stack to recover from stack > overflow (of the main stack) under some circumstances. The configure scr= ipt > did detect the alternate stack. >=20 > I then made the stack overflow by defining an elisp function that did an > infinite recursion. emacs still crashed, but the "segmentation fault" > message was printed twice instead of once. I haven't had a chance yet to > investigate further and try to see what's going on. What I hope is that = the > alternate stack functioned correctly but the code was still not able to > recover for some reason. I've appended below the signal handler in case = you > want to see if you think it ought to work on Cygwin. Thank you. I'll try to test this in the next couple of days. One hint and one question: > The signal handler: >=20 > /* Attempt to recover from SIGSEGV caused by C stack overflow. */ > static void > handle_sigsegv (int sig, siginfo_t *siginfo, void *arg) > { > /* Hard GC error may lead to stack overflow caused by > too nested calls to mark_object. No way to survive. */ > if (!gc_in_progress) > { > struct rlimit rlim; >=20 > if (!getrlimit (RLIMIT_STACK, &rlim)) This getrlimit probably won't work as desired. I just had a quick look how this request is handled. It will return the size of the alternate stack while running the signal handler, rather than the size of the initial thread's stack as required by POSIX. This definitely needs fixing. > { > enum { STACK_DANGER_ZONE =3D 16 * 1024 }; > char *beg, *end, *addr; >=20 > beg =3D stack_bottom; > end =3D stack_bottom + stack_direction * rlim.rlim_cur; > if (beg > end) > addr =3D beg, beg =3D end, end =3D addr; > addr =3D (char *) siginfo->si_addr; > /* If we're somewhere on stack and too close to > one of its boundaries, most likely this is it. */ > if (beg < addr && addr < end > && (addr - beg < STACK_DANGER_ZONE > || end - addr < STACK_DANGER_ZONE)) > siglongjmp (return_to_command_loop, 1); > } > } >=20 > /* Otherwise we can't do anything with this. */ > deliver_fatal_thread_signal (sig); > } >=20 > The code to set up the signal handler on the alternate stack: >=20 > static bool > init_sigsegv (void) > { > struct sigaction sa; > stack_t ss; >=20 > stack_direction =3D ((char *) &ss < stack_bottom) ? -1 : 1; >=20 > ss.ss_sp =3D sigsegv_stack; > ss.ss_size =3D sizeof (sigsegv_stack); ^^^^^^^^^^^^^^^^^^^^^^^ What's that size in bytes? > ss.ss_flags =3D 0; > if (sigaltstack (&ss, NULL) < 0) > return 0; >=20 > sigfillset (&sa.sa_mask); > sa.sa_sigaction =3D handle_sigsegv; > sa.sa_flags =3D SA_SIGINFO | SA_ONSTACK | emacs_sigaction_flags (); > return sigaction (SIGSEGV, &sa, NULL) < 0 ? 0 : 1; > } Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --FiqEyLLt06qkB6ow Content-Type: application/pgp-signature Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJVjV5NAAoJEPU2Bp2uRE+gXd4QAJDhrsC8/R8y+nO/hCQUFUVi KfHcD6T88XUrrZw99mj95WHJKV0q6JkU9SWhUkXNW2znSuK8lBzNAt9ssMkHGz8y 6JRi1pxGuvGZoYpWCxceTKD7hXoQBHt0EOEKsVSaLLeLTWxYWg98ozN0VT1Dwcx1 Dux+9oUxtIZs0YodufAnH7f2YUM+96B3iYKlqzjWjnUzpU+wAkf1pod1o33scwOP HAu62PynZbF/V3ZcV8ep5DwtjKclldOq+mEvex6nRrUvnsRW4q4Zox1dycs9PGrm X7p69CiOR1A5QgT4BCM7XOGt4EQGZMyFyfMErBHeAx4u1hPrwv90DF4Jkw1/AJSk sYP4Ng+NDWv6XubQ1c41hrhj3p13EG5iFwjZBSkROQ8RuI7Euw6MAi9aaxZKGgOT dOs+4RKf+KFUmgeFqWVbQijIQSXyHwVk9yGXr/SCHlFZq653tDrlNP4CK7mHziLX RIgdNJ3e+bRQgVOElUHXg1Za7Ta9KanoWA7nyzGQcO9pF1buKI02bbChA4ZQ2BeZ feqfgPYgBge7B2DWlZmdS+U4C/mox1IEr7Lvv5H0vzbSlAHhfFeuyb2+sYJu8K3Q GRaMzZf6srlsX1geA+bXC7GojEIVuoGfNBKSkhaMaB037QAkEH8NBE/W/m9Iveg/ 0L+/uK44Bk+9ilGEJO/Z =xrtW -----END PGP SIGNATURE----- --FiqEyLLt06qkB6ow--