[FFmpeg-devel] default lock mechanism in libavcodec/utils.c
Reimar.Doeffinger at gmx.de
Thu Feb 20 08:19:09 CET 2014
On 20.02.2014, at 06:57, anshul <anshul.ffmpeg at gmail.com> wrote:
> On 02/20/2014 12:41 AM, Reimar Döffinger wrote:
>> On Wed, Feb 19, 2014 at 05:09:15PM +0530, anshul wrote:
>>> On 02/19/2014 04:46 PM, wm4 wrote:
>>>> This will lead to horrible stuff like library A trying to "unload"
>>>> libavcodec, while library B is still using it. You can't generally use
>>>> this function correctly.
>>> How does that happen "when lib A is loading and lib B is unloading"
>>> What I understand is follow:
>>> libavcodec has been dynamically loaded by libA and libB
>>> both does not know whether libA or libB is using libavcodec
>>> and if libA change some static parameter of libavcodec then libB
>>> will also see the effect.
>>> Something I have documented that this is dangerous(unsafe) function
>>> if it is called when you dont know
>>> whether any thing is using libavcodec.
>> And when would you ever know that? Some user on your system might be
>> using a libc they for fun linked against libavcodec.
>> IMHO this is an example of an API that, at least strictly speaking,
>> is _impossible_ to use correctly.
>> At the very least, you couldn't let anything using this API get
>> into a Linux distribution unless statically linked (which in turn
>> would keep it out of many distributions).
> If any X library that is using libavcodec, but your program(process) is not using the library X
I don't know what that has to do with my example. My example is: your are using libavcodec and you use library X. You _cannot_ know whether X uses libavcodec or not, and if it does at which point of your program's runtime and in which thread (which means race conditions).
> then you can surely state that there is no problem in unloading, because both of the program does
> not share any section. All process have there own space and none interfere with other.
> i did wrote some test program to verify the above statement.
I have 0 idea what your code is supposed to show or what it has to do with the issue.
More information about the ffmpeg-devel