[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Libunwind-devel] SIGFPE and _Unwind_GetIPInfo problem on x86_64 (g+
From: |
Lassi Tuura |
Subject: |
Re: [Libunwind-devel] SIGFPE and _Unwind_GetIPInfo problem on x86_64 (g++-4.5) |
Date: |
Sun, 6 Feb 2011 10:35:14 +0100 |
Hi,
> I've experimented somewhat with throwing exceptions from within a signal
> handler.
> Libunwind seems to work in the case of SIGILL, SIGBUS, SIGSEGV, but not
> always for SIGFPE.
>
> The attached program shall demonstrate a failing SIGFPE-case
> (sigfpe.sh contains all necessary steps to demonstrate this).
>
> The program runs successfully if you use the default gcc unwinding routines,
> but it crashes, if you preload libunwind. The only difference between
> gcc and libunwind seems to be the returned flag `ip_before_ins`
> when calling _Unwind_GetIPInfo. This is also shown in the test program.
>
> As far as I can tell the following happens (See attached backtrace and
> output):
> - personality routine is called for sighandler()-frame (#0)
> - libunwind identifies a signal stack frame (with no personality routine) (#1)
> - personality routine is called for fpe()-frame (#2)
> Here _Unwind_GetIPInfo returns 0 for ip_before_ins because this frame
> is identified as a regular frame.
>
> As I'm not an expert on that unwinding stuff, maybe somebody else on this list
> can explain, why this happens - Is it a feature of gcc or a bug in libunwind?
> :)
If it's different, it would be a bug I think. I do get identical results
though. Here's output on RHEL5-based x86-64 with GCC 4.3.4 (system compiler GCC
4.1.2) and fairly recent libunwind from git, after changing your
__gxx_personality_v0 to test ++counter == 3 (vs. 2):
$ ./sigfpe_ip
ip: 0x2ab9e139e5fd, ip-before-ins: 0
ip: 0x400a80, ip-before-ins: 0
ip: 0x40096d, ip-before-ins: 1
$ LD_PRELOAD=libunwind.so ./sigfpe_ip
ip: 0x2af8f07b65fd, ip-before-ins: 0
ip: 0x400a80, ip-before-ins: 0
ip: 0x40096d, ip-before-ins: 1
Both exit with exit code 0, as they should. The other test program works too:
$ ./sigfpe
caught...
$ LD_PRELOAD=libunwind.so ./sigfpe
caught...
That said I wouldn't recommend throwing exceptions out of signal handlers. If
you have highly controlled code base you might get it to work, but I suspect
you'll have trouble otherwise.
Regards,
Lassi
Re: [Libunwind-devel] SIGFPE and _Unwind_GetIPInfo problem on x86_64 (g++-4.5), Arun Sharma, 2011/02/07