Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 45217 - Force adding -fexceptions to Callback C-libraries
Summary: Force adding -fexceptions to Callback C-libraries
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High blocker (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-20 09:04 UTC by Andreas Pokorny
Modified: 2004-05-05 20:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Pokorny 2004-03-20 09:04:28 UTC
Affected Libraries:
sax interface of libxml
gtk libraries 
pthread functions in glibc
... ( all c-libraries that get function pointers from the caller )

If you do not compile the library with -fexceptions, and throw an exception within the function called from the library the process will be aborted immediately. There is no way to "catch" the exception, the process gets killed right away. This is a dangerous behaviour for a rather common operation, because you cannot free resources aquired by the process before termination. It also makes writing save c++ applications using these libraries impossbile. In my opinion the ebuilds of the affected libraries should add the flag to CFLAGS
temporarly. 

I could supply a small example this evening.. 

Reproducible: Always
Steps to Reproduce:
1. Write a callback function that throws and catches an exception 
   ( e.g. write a button handler for gtkmm )
2. Set the function pointer 
   ( e.g. with pthread_create ... )
3. Compile
4. Link 
5. Run the application
6. open the application using gdb
7. type "run"
8. type ""
Actual Results:  
5 should result in:
"Aborted"
while 8 should result in:
#0  0x405f96d1 in kill () from /lib/libc.so.6
#1  0x4047ba60 in pthread_kill () from /lib/libpthread.so.0
#2  0x4047bdbb in raise () from /lib/libpthread.so.0
#3  0x405f9462 in raise () from /lib/libc.so.6
#4  0x405faa5c in abort () from /lib/libc.so.6
#5  0x4059ff97 in __cxa_call_unexpected ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so
#6  0x4059ffd4 in std::terminate() ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so
#7  0x405a0196 in __cxa_throw ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/libstdc++.so

The result looks like the result you get when you have two active exceptions ..
but thats not the case here.. 


Exception are really common used in C++ application, if you allow people to
comple the affected libraries without that flag you will get a lot of bug
reports of people annoyed about "unstable software"
Comment 1 Andreas Pokorny 2004-03-26 01:21:48 UTC
In the last days I tried to write a minimum example... but i failed
The reason is simple: all minimum examples were working fine, because they did not  include the bug in my main application. I misread the stack output of gdb so I did not notice that I forgot to handle exceptions within a certain callback.
I guess you can close that bug. It is INVALID.. 
Comment 2 SpanKY gentoo-dev 2004-05-05 20:56:52 UTC
as the user said :)