http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59679
Bug ID: 59679 Summary: gcc version 4.7.3 and gcc version 4.5.3 cause an unaligned access exception on NetBSD/Alpha Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: nullnilaki at gmail dot com Using gcc4.7.3 and gcc4.5.3 to compile a Perl v5.18.1. Perl cause an unaligned access exception. ---------------------------------------------------------------- Please read the perl-bug https://rt.perl.org/Public/Bug/Display.html?id=120888 ---------------------------------------------------------------- gcc4.5 and gcc4.7 cause this problem. (I can not compile gcc4.6 and gcc4.8 but I think gcc4.6 and gcc4.8 has some kind of similar bug.) ---------------------------------------------------------------- This problem was caused by compiler's bug. -ftree-ter option makes wrong binary. ---------------------------------------------------------------- -O2 version. (gdb) break scope.c:1217 No source file named scope.c. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (scope.c:1217) pending. (gdb) r perl.pl Starting program: /usr/pkg/bin/perl perl.pl [Switching to LWP 1] Breakpoint 1, Perl_leave_scope (my_perl=0x160505000, base=<optimized out>) at scope.c:1217 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8); (gdb) list 1212 1213 case SAVEt_I16: /* I16 reference */ 1214 *(I16*)ARG0_PTR = (I16)(uv >> 8); 1215 break; 1216 case SAVEt_I8: /* I8 reference */ 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8); 1218 break; 1219 case SAVEt_DESTRUCTOR: 1220 (*arg1.any_dptr)(ARG0_PTR); 1221 break; (gdb) x/10i $pc => 0x1601795c0 <Perl_leave_scope+3648>: extbl t5,0x1,t5 0x1601795c4 <Perl_leave_scope+3652>: ldl t0,0(s1) 0x1601795c8 <Perl_leave_scope+3656>: andnot t0,0xff,t0 0x1601795cc <Perl_leave_scope+3660>: or t5,t0,t5 0x1601795d0 <Perl_leave_scope+3664>: stl t5,0(s1) 0x1601795d4 <Perl_leave_scope+3668>: ldl t3,48(s0) 0x1601795d8 <Perl_leave_scope+3672>: ldl t0,152(s0) 0x1601795dc <Perl_leave_scope+3676>: br 0x160178800 <Perl_leave_scope+128> 0x1601795e0 <Perl_leave_scope+3680>: mov s0,a0 0x1601795e4 <Perl_leave_scope+3684>: ldq t12,-24984(gp) (gdb) p uv $1 = 2574 (gdb) ptype uv type = long unsigned int (gdb) ptype I8 type = signed char (gdb) print /a uv $2 = 0xa0e (gdb) p arg0 $1 = {any_ptr = 0x1605104ee, any_i32 = 1615922414, any_iv = 5910889710, any_uv = 5910889710, any_long = 5910889710, any_bool = 238, any_dptr = 0x1605104ee, any_dxptr = 0x1605104ee} (gdb) p &arg0 Address requested for identifier "arg0" which is in register $s1 (gdb) n pid 436 (perl): unaligned access: va=0x1605104ee pc=0x1601795c4 ra=0x160179124 sp=0x1ffffc698 op=ldl pid 436 (perl): unaligned access: va=0x1605104ee pc=0x1601795d0 ra=0x160179124 sp=0x1ffffc698 op=stl 1218 break; 1218 break; (gdb) p uv $1 = <optimized out> ------------------------------------------------------------------- -O2 -fno-tree-ter version. (gdb) break scope.c:1217 No source file named scope.c. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (scope.c:1217) pending. (gdb) r perl.pl Starting program: /usr/pkg/bin/perl perl.pl [Switching to LWP 1] Breakpoint 1, Perl_leave_scope (my_perl=0x160505000, base=<optimized out>) at scope.c:1217 1217 *(I8*)ARG0_PTR = (I8)(uv >> 8); (gdb) x/10i $pc => 0x160177df0 <Perl_leave_scope+3664>: extbl t5,0x1,t5 0x160177df4 <Perl_leave_scope+3668>: ldq_u t0,0(s1) 0x160177df8 <Perl_leave_scope+3672>: insbl t5,s1,t5 0x160177dfc <Perl_leave_scope+3676>: mskbl t0,s1,t0 0x160177e00 <Perl_leave_scope+3680>: or t5,t0,t5 0x160177e04 <Perl_leave_scope+3684>: stq_u t5,0(s1) 0x160177e08 <Perl_leave_scope+3688>: ldl t3,48(s0) 0x160177e0c <Perl_leave_scope+3692>: ldl t0,152(s0) 0x160177e10 <Perl_leave_scope+3696>: br 0x160177020 <Perl_leave_scope+128> 0x160177e14 <Perl_leave_scope+3700>: unop (gdb) p uv $1 = 2574 (gdb) ptype uv type = long unsigned int (gdb) ptype I8 type = signed char (gdb) print /a uv $2 = 0xa0e (gdb) p arg0 $1 = {any_ptr = 0x1605104ee, any_i32 = 1615922414, any_iv = 5910889710, any_uv = 5910889710, any_long = 5910889710, any_bool = 238, any_dptr = 0x1605104ee, any_dxptr = 0x1605104ee} (gdb) n 1218 break;