[GiNaC-devel] Crash during startup
Richard B. Kreckel
kreckel at thep.physik.uni-mainz.de
Sat Jan 8 22:58:03 CET 2005
On Sat, 8 Jan 2005, Chris Dams wrote:
> On Fri, 7 Jan 2005, Richard B. Kreckel wrote:
> > Theoretically, by making sure the library_init ctor constructs it as well.
> > Maybe using placement new or some such trick.
> Yes, that might be made to work. I hadn't thought about placement new.
It's the same idea as std::ios_base::Init in the C++ standard [18.104.22.168.6].
> Another thing: I think it is wrong that count is a static int of
> library_init. This is given a value in utils.cpp, which may be after the
> point that library_init::library_init() does its work. Shouldn't it be a
> static of the constructor library_init::library_init()?
No, it's a POD integral type which comes pre-initialized by the
linker. So making it a static member is okay.
> The destructor
> isn't doing much anyway.
That's true. (And different from the standard library which
has to flush cout, clog, etc.)
> Here's a patch.
Your patch looks very interesting but something is wrong with it,
although I am unable to see what. It does not fix the original
problem if I revert the patch in integral.cpp. All the tests still
segfault. Also, what's the point in self-assigning those pointers
where they should really just be declarations? And then, the static
member variable initialization is actually okay, as explained above.
I wonder why you are unable to reproduce the bug. For me, it works as
1) Revert the patch in integral.cpp
2) export CXXFLAGS="-ggdb" (Well, several others work too, possibly
any and all)
3) ./configure --disable-shared
5) make check
Since with GNU ld, initialization depends on the order given on the
link line, please check your link line with mine. Here is how
ginac/.libs/libginac.a is created:
ar cru .libs/libginac.a add.o archive.o basic.o clifford.o color.o constant.o ex.o expair.o expairseq.o exprseq.o fail.o fderivative.o function.o idx.o indexed.o inifcns.o inifcns_trans.o inifcns_gamma.o inifcns_nstdsums.o integral.o lst.o matrix.o mul.o ncmul.o normal.o numeric.o operators.o power.o registrar.o relational.o remember.o pseries.o print.o structure.o symbol.o symmetry.o tensor.o utils.o wildcard.o input_parser.o input_lexer.o
And here is how the segfaulting checks/checks executable is created:
g++ -O -o checks check_numeric.o check_inifcns.o check_matrices.o check_lsolve.o genex.o checks.o ../ginac/.libs/libginac.a -L/usr/lib /usr/lib/libcln.so /usr/lib/libgmp.so
Richard B. Kreckel
More information about the GiNaC-devel