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

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


Selon Eric Botcazou <ebotcazou@xxxxxxxxxx>:
> 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.

Did some test with and without my patch and an explicit allegro_exit. I managed
to confuse myself:

no patch, no allegro_exit: "pure virtual function call"
no patch, allegro_exit:    sometimes ok, sometimes "pure virtual..."
patch,    no allegro_exit: ok
patch,    allegro_exit:    ok

Adding "int _module_dont_unload_me_dirty_hack = 0;" to arts.c did not seem to
change anything... BTW, which module are we talking about, allegro arts driver
as a module, or arts itself ? Which would be not-unloaded by the svgalib hack ?

> 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?

Not with the arts C API, which is minimalistic. I haven't looked into arts
native C++ API.

Anyway calling arts_free() more than necessary doesn't seem to hurt. The problem
is with releasing allegro's arts stream. If we want to do it, it must be done
before arts has been freed. If arts is freed before all arts streams have been
released, it issues a warning on the command line.

Though in allegro, the warning doesn't seem to reach the console. And it doesn't
seem to crash anything, either. Humm, then another solution is to not free
allegro's arts stream. This seems to work, and is *much* simpler:

--- src/unix/arts.c.old 2004-01-29 18:39:32.945607832 +0100
+++ src/unix/arts.c     2004-01-29 18:39:49.064157440 +0100
@@ -277,7 +277,7 @@
    free(_al_arts_bufdata);
    _al_arts_bufdata = NULL;

-   arts_close_stream(_al_arts_stream);
    _al_arts_stream = NULL;

    arts_free();

This isn't very clean, but maybe not worse than adding to the atexit mess :-)

> Registering another function to fix a problem with function registering is a
> bit ironic :-)

Agreed :-)

--
Julien Cugnière




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