[vlc-devel] [PATCH] Deprecate vlc_clone_detach()

Romain Vimont rom1v at videolabs.io
Sun Sep 6 19:20:42 CEST 2020


On Sun, Sep 06, 2020 at 07:49:51PM +0300, Rémi Denis-Courmont wrote:
> Le sunnuntaina 6. syyskuuta 2020, 19.17.45 EEST Romain Vimont a écrit :
> > On Sun, Sep 06, 2020 at 04:31:07PM +0300, Rémi Denis-Courmont wrote:
> > > Le sunnuntaina 6. syyskuuta 2020, 16.15.05 EEST Romain Vimont a écrit :
> > > > Hi,
> > > > 
> > > > On Sun, Sep 06, 2020 at 03:32:27PM +0300, Rémi Denis-Courmont wrote:
> > > > > The documention outright lies about LibVLC waiting to make this
> > > > > functon
> > > > > safe. There are no ways to use this function safely other than linking
> > > > > LibVLC statically into the application, which is not *generally*
> > > > > practical.
> > > > 
> > > > I have mixed feelings about this.
> > > > 
> > > > I'm wondering if it would not just be better to just document that
> > > > unloading the libvlc library is undefined behavior.
> > > 
> > > We used to support this until Filip broke it.
> > 
> > If we consider that it is not safe to unload a library (e.g. loaded by
> > VLC, hence module_unneed() not calling dlclose()), then nothing is
> > broken.
> 
> There never was such an option.

Do all dependencies of VLC are unload-safe?

Why don't we call dlclose() on module_unneed()?

> LibVLC runs on run-times that do unload (e.g. MSVCRT, glibc), and run-times 
> that don't (e.g. musl). It runs in frameworks that do close LibVLC and 
> frameworks that don't.
> 
> You can't just arbitrarily remove a combination, especially not the "clean" 
> one.
> 
> And there's really no justifications. A detached thread saves nothing. 
> Literally all you need to keep around until join is a flag/semaphore and a 
> result pointer. Everything can be destroyed when the thread exits even if it 
> is not detached, including all kernel resources.

Detached threads fit some use cases better.

For example (just from last week), if we want to terminate the threads
of an executor when they have no work for more than x seconds (instead
of keeping the threads running indefinitely), who should join them and
when it is the right time to do so?

Joining on delete would defeat the purpose of this behavior (the kernel
resources of all the threads created/destroyed since the creation would
be kept until deletion). Resources of a detached thread are
automatically released immediately.

Regards


More information about the vlc-devel mailing list