GNOME Bugzilla – Bug 391777
GStreamer does not reset SEGV trap handler
Last modified: 2007-01-02 06:42:41 UTC
When GStreamer is loading plugins, it traps SEGV. After it's done, it resets the handler to the default one, and not the previous one. This leads to unhandled segfaults in Mono applications that use GStreamer, as the Mono runtime traps SEGV to translate the dereferencing of null pointers into NullReferenceExceptions. This means applications that have code to handle NullReferenceException can never recover as expected. Instead the application simply crashes.
Created attachment 79168 [details] Test case exposing the issue This can be compiled and run: $ mcs TestGStreamerTrap.cs && mono TestGStreamerTrap.exe aaron@mervperv:~/Desktop$ mono TestGStreamerTrap.exe Attempting to throw a NullReferenceException... OK Attempting to throw a NullReferenceException... OK Attempting to throw a NullReferenceException... Segmentation fault The expected output should be 4 attempts and "OK"s, meaning the SEGV handler was reset to that of the mono runtime.
This is because GStreamer installs a SIGSEGV handler during plugin loading, but then restores the default handler. Patch attached.
Created attachment 79169 [details] [review] restore original signal handler Patch that restores original signal handler.
Applied. 2007-01-01 David Schleef <ds@schleef.org> * gst/gstplugin.c: Restore the previous signal handler for SIGSEGV instead of setting to default, since we may have stolen it away from someone. (i.e., Mono)