Hi Lassi,

thanks for your quick response.

>> 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

In the meantime I ran tests with g++-4.4/4.5/4.6 and with libunwind from git 
and always got the same results.

Interestingly, on another system with a debian-5.0-x86_64/g++-4.3, I had to 
adjust the counter to 3, too.
But libunwind keeps failing:

$ ./sigfpe
caught...
$ ./sigfpe_ip
ip: 0x7f1689bc779d, ip-before-ins: 0
ip: 0x400aa0, ip-before-ins: 0
ip: 0x40098d, ip-before-ins: 1

$ LD_PRELOAD=~/usr/lib/libunwind.so ./sigfpe
terminate called after throwing an instance of 'int'
Aborted
$ LD_PRELOAD=~/usr/lib/libunwind.so ./sigfpe_ip
ip: 0x7ff9f26d779d, ip-before-ins: 0
ip: 0x400aa0, ip-before-ins: 0
ip: 0x40098d, ip-before-ins: 0

@Lassi: Just out of curiosity, did you forget to enable exception unwinding 
support in libunwind (--enable-cxx-exceptions)?

> 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.

Thanks for your recommendation. I currently don't intend to use such code in 
productive software.
I'm just experimenting with that code, because I somehow like the idea of 
throwing exceptions for kernel generated signals in c++.
But that's surely a matter of opinion :)

Regards,
Stefan


_______________________________________________
Libunwind-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to