-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segfault in extractError function #280
Comments
Versions:
|
Thanks! I'll take a proper look in the new year. I'm not sure whether to fix it in the way you have here, although it's probably safer to do so. It might indicate issues in a few other places. I need to check if anywhere else is trying to use The other option is probably to use It's interesting that this issue has not been reported before, which might be due to memory allocator differences, or just that it's rare(?) |
I think an ideal solution would be to have an annotation on that parameter in that function to indicate that this is an input only parameter but JNA does not have such annotation afaik. Yeah it is interesting, I am able to reproduce this issue with 100% reproducibility rate. And able to confidently confirm that the fix in my pull request works. |
A friendly reminder. Does this PR require changes? |
I think it's good, although a test that fail before application and passes after would make it perfect! However, at the moment we need to make a decision on whether we're going to do any further releases of this library. I will merge if and when we decide to do so. Thanks! |
On Mac I am able to reproduce a test crash before fix and a test pass after fix with the following test: @Test
public void testParseLaunchThrowingError() {
ArrayList<GError> errors = new ArrayList<GError>();
assertThrows(GstException.class, () -> {
Gst.parseLaunch("fakesrcc ! fakesinkk", errors);
});
} On Linux I wasn't able to reproduce crash with this test with debug heap enabled so far. While trying to reproduce I found similar memory issues. I get a crash when running tests on Linux with debug heap enabled (with or without fix applied). I was able to isolate crashing tests to EventTest and QueryTest. LD_PRELOAD=/lib/x86_64-linux-gnu/libc_malloc_debug.so.0 MALLOC_CHECK_=3 mvn -Dtest='EventTest,QueryTest' test While this command passes: LD_PRELOAD=/lib/x86_64-linux-gnu/libc_malloc_debug.so.0 MALLOC_CHECK_=3 mvn -Dtest='!EventTest,!QueryTest' test Wanted to share those intermediate results. I will spend a bit more time trying to reproduce the original issue on Linux. |
Hi all,
I encountered SIGSEGV error in Gst.extractError function, here is full error report file:
hs_err_pid32632.log
When a JNA function is invoked with a
Structure.ByReference
parameter, JNA automatically reads the contents of this structure upon completion of the native function call. This step is crucial for propagating any modifications made by the native function back to a corresponding Java class that mirrors the native structure. The implementation responsible for this process can be found here.The seg fault happens when
extractError
function callsg_error_free
function which releases memory used byGErrorStruct
structure.Since
g_error_free
function releases memory used by the passed structure and structure is passed by reference, JNA attempts to read from a memory that has been released. This leads to "use-after-free" bug.I made a fix to prevent JNA from reading structure content after call to
g_error_free
function: #279The text was updated successfully, but these errors were encountered: