segmentation fault on GiNaC-1.2.0 using MinGW on Win XP
Richard B. Kreckel
kreckel at thep.physik.uni-mainz.de
Mon Apr 5 22:32:03 CEST 2004
On Mon, 5 Apr 2004, Johannes Brunen wrote:
> I'm not subscribed to this list, but I have detected a problem with the new release of GiNaC, which I would like to report.
> After properly building GiNaC-1.2.0 on windows XP using the MinGW / MSYS platform I got a segmentation fault on
> starting my demo application. This didn't happen with GiNaC-1.1.7.
> After looking to the source code I found a problem with the current implementation:
> In file uitils.cpp the following constants are defined:
> These are initialized on behalf of constructor library_init() which is called by statement
> static library_init library_initialize from file ex.h (line 53).
> The constructor function_options::function_options(std::string const & n, std::string const & tn)
> in file function.cpp (line 56) calls function initialize() (line 67 )which has a statement
> symtree = 0; in its implementation (line 82).
> Symtree is of type ex which is initialized by ex(int) which calls
> basic & ex::construct_from_int(int i) in file ex.cpp (line 329).
> The relevant line is case 0: return const_cast<numeric &>(_num0);
> Reference counting, now, forces usage of operator-> on the _num0 object.
> Now, here is the problem: It may happen that the construtor of function_options() is called before
> the call of library_init().
> function_options() is called during registration of class container by statement
> GINAC_DECLARE_REGISTERED_CLASS(container, basic) in file container.h (line 130).
> The construction order of static objects in different translation units is undefined in C++. Therefore
> the problem may or may not show up.
Congratulations on your excellent analysis. Well, the fix has been
applied to CVS already:
Richard B. Kreckel
More information about the GiNaC-devel