[vlc-devel] [PATCH 1/2] libvlc: Add Rust API for writing modules in rust

Alexandre Janniaux ajanni at videolabs.io
Sun Sep 20 13:54:15 CEST 2020


Hi,

On Sun, Sep 20, 2020 at 09:29:44AM +0300, Rémi Denis-Courmont wrote:
> Le sunnuntaina 20. syyskuuta 2020, 2.00.20 EEST Romain Vimont a écrit :
> > To solve the problem, you propose to call libc::malloc() from Rust and
> > free() from C (or malloc() from C and libc::free() from Rust). I like
> > this solution, but IIUC, it is not guaranteed to be correct, because the
> > allocators used by Rust and C may be different:
> > > To free the data behind the C pointer you should call a C function
> > > that does it, so that definitely the same C’s allocator is used. If
> > > the pointer comes from C’s malloc, then Rust’s libc::free may work,
> > > except it’s dangerous to do so if Windows DLLs are involved, since
> > > each DLL may have separate runtime.
>
> The VLC code base has been exchanging heap allocations and file descriptors
> between DLLs all the time. It's been working fine, and at this point, it is
> very deeply ingrained into the code base, so it has to work fine.

I agree that VLC tree is not subject to the issue but...

> This problem only exists if you set up the build system in a stupid manner
> like LAVfilters does.

... it also affects out-of-tree plugins, so the design of
the core interaction should probably be taken into account
if such ownership echanges exist without wrapping the
memory destruction.

> It might be a problem if you want to use LibVLC from a Rust application. But I
> believe that that's out of scope of this patchset.

I'm not sure I see the issues with regards to LibVLC though,
since we have release methods.


More information about the vlc-devel mailing list