Subject: Mathemagix
List archive
- From: Joris van der Hoeven <address@concealed>
- To: address@concealed
- Subject: Fixes initialization/termination
- Date: Mon, 25 Feb 2008 12:24:50 +0100
Hi *,
I (hopefully) fixed a long-standing bug concerning the correct termination
of Mathemagix. For anyone interested (and in order to avoid similar bugs
yourself) this is what happened:
Mathemagix uses global tables for all literal and for all compound objects,
which are defined as static tables of the mixed_symbol class.
Now the following could happen:
----- Initialization of globals -----
...
1) Some global variable 'generic v' gets initialized with a dummy.
...
----- Main execution
...
2) Someone asks for a compound object for the first time.
...
3) The variable 'v' is set with a compound object
...
----- Destruction of globals and static variables -----
...
4) The static table of compound objects gets destroyed
...
5) The global variable 'v', which still contains a compound object,
gets destroyed.
...
We see here a major flaw concerning the use of static class variables:
C++ does *not* check whether instances of the class are still alive
when destroying the static class variables. This bad behaviour therefore
has to be corrected manually. In our case, this can be done by replacing
the symbol table by a pointer to a symbol table and destroying the table
precisely when it becomes empty.
The above bug caused me to introduce some dirty hacks,
which I also removed. In particular, initialization/termination
of modules is now done by defining a my_package_instance class,
whose constructor is the initialization routine and whose destructor
is the termination routine. One then simply defines one global dummy
variable of this class. The mmx_application class has been removed.
Please use new mechanism for local initialization/termination
of your modules.
Best wishes, Joris
- Fixes initialization/termination, Joris van der Hoeven, 02/25/2008
Archive powered by MHonArc 2.6.18.