[GiNaC-devel] Crash during startup
Richard B. Kreckel
kreckel at thep.physik.uni-mainz.de
Fri Jan 7 22:13:03 CET 2005
On Fri, 7 Jan 2005, Chris Dams wrote:
> Ah! Now, after some thinking, I think I understand it. _ex0 is initialized
> at the point when utils.o is initialized, which may well be after
> integral::relative_integration_error is intialized.
This appears to be the problem.
> > If that analysis is correct there appears to be a loophole in the
> > initialization order scheme. I wonder how that can be fixed without
> > creating a big mess in utils.cpp...
> Well, it makes me wonder why there is such a thing as a library_init.
> After all, it appears that just writing
> ex integral::relative_integration_error = 1e-8;
> is also allowed. Why is not that done for all static objects, such as
Because of object sharing when there are more than one ex representing the
same number. That's an efficiency argument.
> The only thing is that other static objects, should not be using
> _ex0, as I did with my .evalf(). As far as I understand library_init was
> introduced to solve this "problem", however is the problem solvable at
Theoretically, by making sure the library_init ctor constructs it as well.
Maybe using placement new or some such trick.
> After all, _ex0 exists because it is initialized in some *.o file
> and, I think, it should not be initialized in multiple *.o files, because
> that would cause errors for multiple definitions.
It is initialized in utils.o since it is defined in utils.cpp. Note that
it is correctly declare extern in all other translation units.
> Since nobody appears to
> be guaranteeing anything about the order in which the different *.o files
> are intialized, _ex0 should not be used in a static object anywhere, no
> matter what kind of initialization gymnastics you are going to add to
Huh? Right now the gymnastics is not enough! That doesn't mean that
there is no proper gymnastics.
> > Your patch seems to work, thanks a lot! The patch below seems to fix the
> > problem just as well. By virtue of ex::construct_from_double(double) it
> > should be equivalent to your patch. If you have no objections, I'll
> > commit it.
> > +ex integral::relative_integration_error = 1e-8;
> Fine with me!
Richard B. Kreckel
More information about the GiNaC-devel