From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 2/3] Provide ucontext to signal handlers
Date: Sat, 04 Apr 2015 08:40:00 -0000 [thread overview]
Message-ID: <20150404084014.GW13285@calimero.vinschen.de> (raw)
In-Reply-To: <551F0FA2.2020304@dronecode.org.uk>
[-- Attachment #1: Type: text/plain, Size: 2624 bytes --]
On Apr 3 23:09, Jon TURNEY wrote:
> On 01/04/2015 15:22, Corinna Vinschen wrote:
> >On Apr 1 14:19, Jon TURNEY wrote:
> >>Add ucontext.h header, defining ucontext_t and mcontext_t types.
> >>
> >>Provide sigaction sighandlers with a ucontext_t parameter, containing stack and
> >>context information.
> >>
> >> * include/sys/ucontext.h : New header.
> >> * include/ucontext.h : Ditto.
> >> * exceptions.cc (call_signal_handler): Provide ucontext_t
> >> parameter to signal handler function.
> >
> >Patch is ok with a single change: Please add a "FIXME?" comment to:
> >
> > else
> > RtlCaptureContext();
> >
> >On second thought, calling RtlCaptureContext here is probably wrong.
>
> Wrong and also dangerous.
>
> This causes random crashes on x86.
>
> It seems that RtlCaptureContext requires the framepointer of the calling
> function in ebp, which it uses to report the rip and rsp of it's caller.
>
> It also seems that gcc can decide to optimize the setting of the
> framepointer away, irrespective of the fact that -fomit-frame-pointer is not
> used when building exceptions.cc
>
> If _cygtls::call_signal_handler() happens to get called with ebp pointing to
> an invalid memory address, as seems to happen occasionally, we will fault in
> RtlCaptureContext. (in all cases, the eip and ebp in the returned context
> are incorrect)
>
> I wrote the attached patch, which fakes a callframe for RtlCaptureContext to
> avoid these possible crashes, but this needs more work to correctly report
> eip and ebp
Maybe it's simpler than that? Looking into the GCC info pages, I found
this:
Starting with GCC version 4.6, the default setting (when not
optimizing for size) for 32-bit GNU/Linux x86 and 32-bit Darwin x86
targets has been changed to '-fomit-frame-pointer'. The default
can be reverted to '-fno-omit-frame-pointer' by configuring GCC
with the '--enable-frame-pointer' configure option.
Enabled at levels '-O', '-O2', '-O3', '-Os'.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So it seems adding -fomit-frame-pointer file by file in Makefile.in
(when building with -O2) is moot and only has an effect when building
unoptimized, otherwise all files are built with -fomit-frame-pointer
anyway.
So, what if we drop all the -fomit-frame-pointer from Makefile.in and
add an
exceptions_CFLAGS:=-fno-omit-frame-pointer
Does that help?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-04-04 8:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 13:20 [PATCH 0/3] Make detailed exception information available to signal handlers (v4) Jon TURNEY
2015-04-01 13:20 ` [PATCH 3/3] Add cygwin_internal() operation to retrieve the EXCEPTION_RECORD from a siginfo_t * Jon TURNEY
2015-04-01 14:23 ` Corinna Vinschen
2015-04-01 13:20 ` [PATCH 1/3] Rename struct ucontext to struct __mcontext Jon TURNEY
2015-04-01 14:01 ` Corinna Vinschen
2015-04-01 13:20 ` [PATCH 2/3] Provide ucontext to signal handlers Jon TURNEY
2015-04-01 14:22 ` Corinna Vinschen
2015-04-01 17:37 ` Jon TURNEY
2015-04-01 17:53 ` Corinna Vinschen
2015-04-23 13:53 ` Jon TURNEY
2015-04-23 15:32 ` Corinna Vinschen
2015-04-03 22:09 ` Jon TURNEY
2015-04-04 8:40 ` Corinna Vinschen [this message]
2015-04-04 16:06 ` Jon TURNEY
2015-04-05 16:58 ` Jon TURNEY
2015-04-07 10:17 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150404084014.GW13285@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin-patches@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).