radek-k / FFMediaToolkit

FFMediaToolkit is a cross-platform video decoder/encoder library for .NET that uses FFmpeg native libraries. It supports video frames extraction, reading stream metadata and creating videos from bitmaps in any format supported by FFmpeg.
MIT License
352 stars 56 forks source link

Crash on Dispose after decoding mp3 file audio #65

Closed kskalski closed 3 years ago

kskalski commented 3 years ago

I was trying the current develop version (after changes from @yodadude2003) of Audio decoding on mp3 file and it crashes when disposing with Program „[21944] FFMediaAudio.exe” zakończył działanie z kodem -1073740940 (0xc0000374).

I prepared a sample program that I'm using to read audio: https://github.com/kskalski/snippets/tree/master/FFMediaToolkitTest It seems to crash this way always and on any mp3 file. When using earlier version of library it works fine (the API is also slightly different)

IsaMorphic commented 3 years ago

I believe I have noticed this happening in my own code as well. It only appears to happen sometimes for me (possible race condition?), and not just with audio either. I think it may have to do with the library attempting to dispose of or destroy memory that it does not own anymore (i.e redundant disposal of media packets). I will investigate this as soon as I can and try to devise a solution once I have a better understanding of the nature of the problem.

radek-k commented 3 years ago

I've fixed this bug. The crash was caused by the redundant disposal of the avio file buffer, which was already released by the avformat_close_input method call.