[jamming] Segfault w/ GCC 4.2

Ryan Hill dirtyepic at gentoo.org
Thu May 17 19:40:48 PDT 2007


Ryan Hill wrote:
> Building jam-2.5 with GCC 4.2 is causing a segfault when jam0 is run.
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0804bf3d in hashitem (hp=0x805f2e0, data=0xbffb2588, enter=1) at
> hash.c:108
> 108 keyval = *b;
> (gdb) bt
> #0 0x0804bf3d in hashitem (hp=0x805f2e0, data=0xbffb2588, enter=1) at
> hash.c:108
> #1 0x0804f279 in newstr (string=0x50891424 <Address 0x50891424 out of
> bounds>) at newstr.c:52
> #2 0x08050a41 in addsettings (head=0x0, setflag=0, symbol=0x50891424
> <Address 0x50891424 out of bounds>, value=0x80a4168) at rules.c:253
> #3 0x0804a08a in evaluate_rule (rulename=0x8060520 "Depends",
> args=0xbffb2614, result=0x0) at compile.c:586
> #4 0x0804a307 in compile_rule (parse=0x807cd80, args=0xbffb2684,
> jmp=0xbffb26ac) at compile.c:518
> #5 0x08049933 in compile_rules (parse=0x80a1490, args=0xbffb2684,
> jmp=0xbffb26ac) at compile.c:630
> #6 0x0804f59a in parse_file (f=0x8058150 "+") at parse.c:59
> #7 0x0804c966 in main (argc=-1074056776, argv=0x0, arg_environ=0x3) at
> jam.c:336
> 
> https://bugs.gentoo.org/show_bug.cgi?id=173703

It looks like this is caused by GCC 4.2 enforcing strict aliasing at
-O2.  -fno-strict-aliasing works around it.  ftjam-2.5.3-rc1 is also
affected.

gcc -o jam0 -g -O2 -Wstrict-aliasing builtins.c command.c compile.c
execnt.c execunix.c execvms.c expand.c filent.c fileos2.c fileunix.c
filevms.c glob.c hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c
lists.c make.c make1.c newstr.c option.c parse.c pathunix.c pathvms.c
regexp.c rope.c rules.c scan.c search.c spawn.c spawnmac.c spawnnt.c
spawnos2.c spawnunix.c timestamp.c variable.c
hdrmacro.c: In function 'macro_headers':
hdrmacro.c:110: warning: dereferencing type-punned pointer will break
strict-aliasing rules
hdrmacro.c: In function 'macro_header_get':
hdrmacro.c:133: warning: dereferencing type-punned pointer will break
strict-aliasing rules
newstr.c: In function 'newstr':
newstr.c:52: warning: dereferencing type-punned pointer will break
strict-aliasing rules
rules.c: In function 'bindrule':
rules.c:62: warning: dereferencing type-punned pointer will break
strict-aliasing rules
rules.c: In function 'bindtarget':
rules.c:89: warning: dereferencing type-punned pointer will break
strict-aliasing rules
timestamp.c: In function 'timestamp':
timestamp.c:90: warning: dereferencing type-punned pointer will break
strict-aliasing rules
timestamp.c:116: warning: dereferencing type-punned pointer will break
strict-aliasing rules
timestamp.c:141: warning: dereferencing type-punned pointer will break
strict-aliasing rules
timestamp.c: In function 'time_enter':
timestamp.c:187: warning: dereferencing type-punned pointer will break
strict-aliasing rules
variable.c: In function 'var_get':
variable.c:235: warning: dereferencing type-punned pointer will break
strict-aliasing rules
variable.c: In function 'var_enter':
variable.c:327: warning: dereferencing type-punned pointer will break
strict-aliasing rules
chmod a+w jambase.c
./jam0
make: *** [all] Segmentation fault


-- 
                                where to now? if i had to guess
dirtyepic gentoo org        i'm afraid to say antarctica's next
9B81 6C9F E791 83BB 3AB3  5B2D E625 A073 8379 37E8 (0x837937E8)


More information about the jamming mailing list