FFmpeg random SIGSEGV calling av_dump_format on wrapper
zt64 opened this issue · 3 comments
Hi
I'm having a very strange issue. I'm using the bytedeco ffmpeg preset and I made a class that wraps the native classes from bytedeco. It's very simple:
class AVFormatContextWrapper(internal val native: org.bytedeco.ffmpeg.avformat.AVFormatContext)
override fun dumpFormat(
index: Int,
url: String,
isOutput: Boolean
) {
av_dump_format(native, index, url, if (isOutput) 1 else 0)
}
And an instance is created like this:
val formatContext = avformat_alloc_context()
avformat_open_input(
formatContext,
url,
null,
null
).checkError()
return AVFormatContextWrapper(formatContext)
The issue is sometimes when calling certain methods on this wrapper class it will lead to a SIGSEGV, but sometimes it runs fine. All the methods do is pass the native field to the methods. Now if I call the methods directly without the wrapper class, I haven't been able to produce a SIGSEGV, but it's far less convenient and defeats the purpose of my project. I think I've narrowed it down to it being a result of some optimization but I don't know how to verify that and fix it.
I've also seen a few times it produced SIGSEGV when closing using this function
fun close() {
avformat_close_input(native)
}
It happens much less than av_dump_format. In my entire test I remux a video and its only those two methods that have caused a crash
Please try to set the "org.bytedeco.javacpp.nopointergc" system property to "true".
Thank you for the quick response. I think that did make the crashes stop. Either that or it's very very rare and it just hasn't happened again. I'm gonna keep developing/testing and see what happens
That probably means you're allocating some struct in Java, but not keeping any Java references anywhere, so it gets garbage collected