Re: program crashes on startup when compiled with 'recent' gcc
Zdeněk Sojka
zsojka@seznam.cz
Tue Oct 6 14:53:00 GMT 2009
Thanks for your reply!
> I was not able to recreate this problem with the current sources.
I am able to reproduce it with current snapshots
at x86_86-pc-linux-gnu, trunk r152485 (20091006)
at i686-pc-linux-gnu, 20091001
I tried various binutils versions (2.18, 2.19, 2.20 from 20090905) with no success
(my fault was not mentioning used architecture)
The problem may be in placing the symbol in wrong section group as
- .section .bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZZN1A4InitEvE1i,comdat
+ .section .bss._ZGVZN1A4InitEvE1i,"awG",@nobits,_ZGVZN1A4InitEvE1i,comdat
applied (at least to) file.s fixes the problem.
Failing instruction is:
0x0000000000400853 <_ZN1A4InitEv+63>: mov %rax,-0x40085a(%rip) # 0x0
(writing to NULL)
which is
movq %rax, _ZZN1A4InitEvE1i(%rip)
in .s file
Now, I am not sure whether it's gcc's or binutils' problem...
Any ideas?
> It looks valid to me.
Thanks for review.
> I think that should normally be valid too--static variables are always
> initialized to zero bits.
>
Now I remember what was the problem about - destructors are called in reverse order of constructors finishing, so if a static object refers other static object in its both constructor and destructor, it may cause crash.
Zdenek
More information about the Gcc-help
mailing list