Re: [AD] aRts "pure virtual function call"

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> After your explanation of the SVGAlib case, I checked: the problem is not
> the same. After some tests, it appears the arts module is unloaded *after*
> the call to remove_sound(). And I double checked, even if I disable module
> unloading for arts, the crash still happens.

Modules are unloaded by allegro_exit after all remove_* functions have been 
called, through the system_driver->exit call.  Your problem is indeed not 
the same as the SVGAlib one, but I think the latter problem also affects 
aRts: what happens if you add a call to allegro_exit at the end of the 
program?  I suppose that the program would crash, like in the SVGAlib case, 
because the exit machinery would try to call the aRts-registered function 
that is not there anymore.

So I think the same fix that was applied to the SVGAlib module should be 
applied to the aRts modules (as well as to every single module that 
registers anything via atexit).  Of course this won't fix your original 
problem.

> The problem is similar, though. Arts registers its own shutdown function
> with atexit, and does so *after* allegro has registered allegro_exit with
> atexit (because install_sound is called *after* allegro_init). The result
> is that when the program ends, arts shuts itself down, and *then* allegro
> tries to remove_sound(), making the program crash.

So the problem is basically a double-free bug.  Is there any mean to detect 
via the aRts API that arts_free() has already been called?

> Anyway, the patch I sent Works For Me (TM) :-). But it register itself
> again with atexit every time the sound is installed. I can make it
> register itself only once, but then it relies on the fact that arts itself
> registers itself only once.

Registering another function to fix a problem with function registering is a 
bit ironic :-)  But I guess we will eventually have to resort to using it if 
we can't find anything better.

-- 
Eric Botcazou




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/