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:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type:content-transfer-encoding; | |
q=dns; s=default; b=sNpMwIk8a7PSE/UOflzjzdZPQ+P5YUP9X2BWHs1EjTr | |
YIaF+WVxEn5rJBsURGtDKe+q4gTT3bMf7PMKTQSrzSHzYNXqg+v0uDEB2AVk1n77 | |
yP7+dHgRLPPTjZI4rFD6Su71M1B4YU+w2y6zUlZjQPRxRhngdcoHAStP04sZF3Iw | |
= | |
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:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type:content-transfer-encoding; | |
s=default; bh=iSGjTDI7mh89D2fEKg3BUGJfbvc=; b=gWWZJlg19GMbzVDPM | |
aklJ2tG1KavUKnLbu2vLpfCoJBVxIReO/iPKeC4UgIpvAoPao0cdGZbfZveqYKI1 | |
lRmrTvn+5T0Zbhi0oJX94B6+WsBI6QwOJODFmfNFmG2phpXVaMti/WaCD9VGE17q | |
p3NsszlZn40tFojcayuRKATRCE= | |
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=-2.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 |
X-HELO: | limerock02.mail.cornell.edu |
X-CornellRouted: | This message has been Routed already. |
Message-ID: | <558D62D7.8010709@cornell.edu> |
Date: | Fri, 26 Jun 2015 10:33:59 -0400 |
From: | Ken Brown <kbrown AT cornell DOT edu> |
User-Agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: [ANNOUNCEMENT] TEST RELEASE: Cygwin 2.1.0-0.1 |
References: | <announce DOT 20150620205512 DOT GA28301 AT calimero DOT vinschen DOT de> <558706D5 DOT 1020508 AT cornell DOT edu> <20150622110835 DOT GE28301 AT calimero DOT vinschen DOT de> <20150626111249 DOT GS31223 AT calimero DOT vinschen DOT de> <558D3F4C DOT 6090207 AT cornell DOT edu> <20150626141437 DOT GV31223 AT calimero DOT vinschen DOT de> |
In-Reply-To: | <20150626141437.GV31223@calimero.vinschen.de> |
X-IsSubscribed: | yes |
Hi Corinna, On 6/26/2015 10:14 AM, Corinna Vinschen wrote: > 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, SS_DISABLE, >>>>>> MINSIGSTKSZ, SIGSTKSZ. >>>>> [...] >>>> [...] >>> did you have a chance to test this a bit, in the meantime? >> >> 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 script >> did detect the alternate stack. >> >> 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: >> >> /* 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; >> >> 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 = 16 * 1024 }; >> char *beg, *end, *addr; >> >> beg = stack_bottom; >> end = stack_bottom + stack_direction * rlim.rlim_cur; >> if (beg > end) >> addr = beg, beg = end, end = addr; >> addr = (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); >> } >> } >> >> /* Otherwise we can't do anything with this. */ >> deliver_fatal_thread_signal (sig); >> } >> >> The code to set up the signal handler on the alternate stack: >> >> static bool >> init_sigsegv (void) >> { >> struct sigaction sa; >> stack_t ss; >> >> stack_direction = ((char *) &ss < stack_bottom) ? -1 : 1; >> >> ss.ss_sp = sigsegv_stack; >> ss.ss_size = sizeof (sigsegv_stack); > ^^^^^^^^^^^^^^^^^^^^^^^ > > What's that size in bytes? SIGSTKSZ >> ss.ss_flags = 0; >> if (sigaltstack (&ss, NULL) < 0) >> return 0; >> >> sigfillset (&sa.sa_mask); >> sa.sa_sigaction = handle_sigsegv; >> sa.sa_flags = SA_SIGINFO | SA_ONSTACK | emacs_sigaction_flags (); >> return sigaction (SIGSEGV, &sa, NULL) < 0 ? 0 : 1; Ken -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |