Repository navigation
fix(linux): disable GStreamer's segfault trap so plugin loads can't kill the JVM - #268
Closed
muthuraj57 wants to merge 1 commit into
Closed
muthuraj57 wants to merge 1 commit into
muthuraj57 wants to merge 1 commit into
Conversation
…ill the JVM While GStreamer loads a plugin it installs its own SIGSEGV handler. The JVM raises SIGSEGV on purpose (stack banging, implicit null checks, safepoint polls) and handles it itself; if one lands during a plugin load, GStreamer's handler prints "Caught a segmentation fault while loading plugin file" and calls exit(-1), so the app dies with exit code 255. Call gst_segtrap_set_enabled(FALSE) before gst_init().
Owner
|
Thank you! The code of this library now lives in the Nucleus repository (the media modules), see the README and the migration guide. This is still relevant, so it continues in NucleusFramework/Nucleus#995. Closing here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Linux the app can exit with code 255 while a video opens, with this in the log:
GStreamer's segfault trap is on by default. While GStreamer loads a plugin it installs its own SIGSEGV handler. The JVM raises SIGSEGV on purpose (stack banging, implicit null checks, safepoint polls) and handles it itself. If one of those lands during a plugin load, GStreamer's handler catches it and calls
exit(-1), which ends the whole process. Slow plugins make this likely: the NVIDIA decoder plugin takes about 1.4 s to load, so on machines with an NVIDIA GPU the first video often killed the app.Fix
gst_init_func(run once throughpthread_onceinnvp_create) now callsgst_segtrap_set_enabled(FALSE)beforegst_init(). A plugin that really crashes then crashes the JVM, which writes its own crash report.Verification
I used a standalone JNI harness on Ubuntu x86-64 with an NVIDIA GPU. It loads
libNativeVideoPlayer.so, callsnCreatePlayer(which runsgst_init), then loadslibgstnvcodec.sowhile a Java thread keeps overflowing its stack.