-
Notifications
You must be signed in to change notification settings - Fork 325
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
Fix crash dereferencing freed pointer #951
Fix crash dereferencing freed pointer #951
Conversation
If the producer is deleted by the application before the avformat_producer is freed from the cache, then the avformat_producer destructor might try to access the freed producer. Hold a reference to the producer until the avformat_producer is also closed.
It does fix the problem I experienced in the comment on the commit. However, when I run the following unit test
On master branch it uses up to 170 MiB of RES (RSS) in htop or top, but on this branch it uses up to 795M. Now, that is probably due to the high frequency of mlt_cache utilization and its eventual cleanup. Now, in a real world test I open a recent Shotcut project with 13 clips, proxy turned on, and play it twice through. This branch reaches up to ~1500M whereas master ~1300. Now, that is without editing, which the process of creates and destroys many producers: open the same project, in a long timeline clip, make 17 splits, play through them, undo all of them, redo all of them, and play through them again. master uses ~1800, and this branch up to ~2230. What do you make of these results? I do think this is more thread safe since the setting of |
What do you think of this to add thread safety? I do not think the additional reference is really necessary as only the
|
Looks good. I think this strategy to synchronize it is better than reference counting. Do you need to close the cache item? For producer_close(), I would suggest:
|
OK, so you are using
It no longer fixes the crashing/deadlocking! Only also checking |
Unexpected! I guess we do not fully understand the interactions leading up to the problem. I agree - combine the best of all of them an hope for the best. |
If the producer is deleted by the application before the avformat_producer is freed from the cache, then the avformat_producer destructor might try to access the freed producer.
Hold a reference to the producer until the avformat_producer is also closed.