[Bug go/80914] gcc-go binaries don't run

2017-10-11 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #12 from Steven Noonan  ---
Oh this is kind of interesting. It runs fine at '-O1 -ggdb3'

$ go.gcc test -o testbin -gccgoflags '-O1 -ggdb3
-Wl,--compress-debug-sections=zlib'
OK: 136 passed
PASS
ok  github.com/twstrike/ed448   0.289s

And at '-O0 -g0':

$ go.gcc test -o testbin1 -gccgoflags '-O0 -g0
-Wl,--compress-debug-sections=zlib'
OK: 136 passed
PASS
ok  github.com/twstrike/ed448   0.496s



But not at '-O0 -ggdb3':

$ go.gcc test -o testbin -gccgoflags '-O0 -ggdb3
-Wl,--compress-debug-sections=zlib'
fatal error: ranges offset out of range

goroutine 1 [running, locked to thread]:
fatal error: ranges offset out of range
panic during panic

goroutine 1 [running, locked to thread]:
fatal error: ranges offset out of range
stack trace unavailable
exit status 4
FAILgithub.com/twstrike/ed448   0.054s

[Bug go/80914] gcc-go binaries don't run

2017-10-11 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #11 from Steven Noonan  ---
Weird, I wonder why you can't repro it.

I built with this to get a stack trace (I assume -O and -ggdb work properly
when placed here):

$ go.gcc test -o testbin -gccgoflags '-O0 -ggdb3
-Wl,--compress-debug-sections=zlib'

Added a breakpoint on exit() and this was the call stack:


(gdb) bt
#0  0x75a3d4a0 in exit () from /usr/lib/libc.so.6
#1  0x77272217 in runtime.startpanic () at
/build/gcc-multilib-trunk/src/gcc/libgo/go/runtime/panic.go:859
#2  0x77261785 in runtime.throw (s=...) at
/build/gcc-multilib-trunk/src/gcc/libgo/go/runtime/panic.go:806
#3  0x76df4181 in runtime_throw (s=s@entry=0x7750cae1 "ranges
offset out of range") at
/build/gcc-multilib-trunk/src/gcc/libgo/runtime/panic.c:13
#4  0x76df1cf3 in error_callback (data=data@entry=0x755cca30,
msg=msg@entry=0x7750cae1 "ranges offset out of range",
errnum=errnum@entry=0) at
/build/gcc-multilib-trunk/src/gcc/libgo/runtime/go-callers.c:154
#5  0x77384a98 in add_unit_ranges (addrs=0x755cbf40,
data=0x755cca30, error_callback=0x76df1cc0 ,
dwarf_ranges_size=0, dwarf_ranges=0x0, is_bigendian=0, base=0, ranges=640,
u=0x77f7a920, base_address=0, state=0x77f9d000) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/dwarf.c:1195
#6  find_address_ranges (state=state@entry=0x77f9d000,
base_address=base_address@entry=0, unit_buf=unit_buf@entry=0x755cbfa0,
dwarf_str=dwarf_str@entry=0x77f6 "uint16",
dwarf_str_size=dwarf_str_size@entry=87720, dwarf_ranges=dwarf_ranges@entry=0x0,
dwarf_ranges_size=0, is_bigendian=0, error_callback=0x76df1cc0
, data=0x755cca30, u=0x77f7a920, addrs=0x755cbf40)
at /build/gcc-multilib-trunk/src/gcc/libbacktrace/dwarf.c:1356
#7  0x77387355 in build_address_map (addrs=0x755cbf40,
data=0x755cca30, error_callback=0x76df1cc0 ,
is_bigendian=0, dwarf_str_size=87720, dwarf_str=0x77f6 "uint16",
dwarf_ranges_size=0, dwarf_ranges=0x0, dwarf_abbrev_size=4564,
dwarf_abbrev=0x77f76000
"\001\021\001%\016\023\v\003\016\033\016\021\001\022\a\020\027",
dwarf_info_size=152763, dwarf_info=0x7451b000 "\361\026", base_address=0,
state=0x77f9d000) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/dwarf.c:1498
#8  build_dwarf_data (data=0x755cca30, error_callback=0x76df1cc0
, is_bigendian=0, dwarf_str_size=87720,
dwarf_str=0x77f6 "uint16", dwarf_ranges_size=0, dwarf_ranges=0x0,
dwarf_abbrev_size=4564, dwarf_abbrev=0x77f76000
"\001\021\001%\016\023\v\003\016\033\016\021\001\022\a\020\027",
dwarf_line_size=0, dwarf_line=0x0, dwarf_info_size=152763,
dwarf_info=0x7451b000 "\361\026", base_address=0, state=0x77f9d000) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/dwarf.c:2935
#9  backtrace_dwarf_add (state=state@entry=0x77f9d000,
base_address=base_address@entry=0, dwarf_info=0x7451b000 "\361\026",
dwarf_info_size=152763, dwarf_line=0x0, dwarf_line_size=0,
dwarf_abbrev=0x77f76000
"\001\021\001%\016\023\v\003\016\033\016\021\001\022\a\020\027",
dwarf_abbrev_size=4564, dwarf_ranges=0x0, dwarf_ranges_size=0,
dwarf_str=0x77f6 "uint16", dwarf_str_size=87720, is_bigendian=0,
error_callback=0x76df1cc0 , data=0x755cca30,
fileline_fn=0x755cc598) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/dwarf.c:2995
#10 0x7738ab49 in elf_add () at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/elf.c:3027
#11 0x7738aff2 in backtrace_initialize
(state=state@entry=0x77f9d000, filename=filename@entry=0x7fffce44
"/home/steven/Development/gocode/src/github.com/twstrike/ed448/testbin",
descriptor=3, error_callback=error_callback@entry=0x76df1cc0
, data=data@entry=0x755cca30,
fileline_fn=fileline_fn@entry=0x755cc648) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/elf.c:3152
#12 0x773878d7 in fileline_initialize
(state=state@entry=0x77f9d000,
error_callback=error_callback@entry=0x76df1cc0 ,
data=data@entry=0x755cca30) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/fileline.c:143
#13 0x77387a02 in backtrace_pcinfo (state=0x77f9d000,
pc=140737335205254, callback=0x76df1a40 ,
error_callback=0x76df1cc0 , data=0x755cca30) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/fileline.c:177
#14 0x77387fb7 in unwind (context=,
vdata=0x755cc9e0) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/backtrace.c:91
#15 0x75dcd349 in _Unwind_Backtrace (trace=trace@entry=0x77387f10
, trace_argument=trace_argument@entry=0x755cc9e0) at
/build/gcc-multilib-trunk/src/gcc/libgcc/unwind.inc:295
#16 0x7738804c in backtrace_full (state=0x77f9d000,
skip=skip@entry=0, callback=callback@entry=0x76df1a40 ,
error_callback=error_callback@entry=0x76df1cc0 ,
data=data@entry=0x755cca30) at
/build/gcc-multilib-trunk/src/gcc/libbacktrace/backtrace.c:127
#17 0x76df1d87 in runtime_callers

[Bug go/80914] gcc-go binaries don't run

2017-10-11 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #10 from Ian Lance Taylor  ---
I can't recreate the problem.  I did the same commands in
github.com/twstrike/ed448 and they worked for me.

Using `go test -c -gccgoflags -Wl,--compress-debug-sections=zlib` to generate
an executable, and using `readelf -S --wide` to look at the section headers, I
can see that the debug sections are compressed:

  [31] .debug_info   PROGBITS 1e15d8 012fb5 00   C  
0   0  1
  [32] .debug_abbrev PROGBITS 1f458d 00062d 00   C 
0   0  1
  [33] .debug_arangesPROGBITS 1f4bc0 d9 00   C 
0   0 16
  [34] .debug_line   PROGBITS 1f4c99 00782b 00   C 
0   0  1
  [35] .debug_strPROGBITS 1fc4c4 00626e 01 MSC 
0   0  1
  [36] .debug_ranges PROGBITS 202732 000201 00   C 
0   0  1
  [37] .debug_locPROGBITS 202933 000b62 00   C 
0   0  1

[Bug go/80914] gcc-go binaries don't run

2017-10-11 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #9 from Steven Noonan  ---
(In reply to Ian Lance Taylor from comment #8)
> Which version of GCC are you using in comment #7?

Oops, forgot to mention that bit. Built from trunk a few hours ago:

$ go.gcc version
go version go1.9 gccgo (GCC) 8.0.0 20171010 (experimental) linux/amd64

[Bug go/80914] gcc-go binaries don't run

2017-10-10 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #8 from Ian Lance Taylor  ---
Which version of GCC are you using in comment #7?

[Bug go/80914] gcc-go binaries don't run

2017-10-10 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #7 from Steven Noonan  ---
With the compressed debug section support added to libbacktrace, gccgo will run
fine when built using a binutils configured with
--enable-compressed-debug-sections=all. However, programs built with that gccgo
+ binutils will crash:

(Using the github.com/twstrike/ed448 go package as an example)

$ go.gcc test -gccgoflags -Wl,--compress-debug-sections=none
OK: 136 passed
PASS
ok  github.com/twstrike/ed448   0.366s

$ go.gcc test -gccgoflags -Wl,--compress-debug-sections=zlib
fatal error: ranges offset out of range

runtime stack:
fatal error: ranges offset out of range
panic during panic

runtime stack:
fatal error: ranges offset out of range
stack trace unavailable
exit status 4
FAILgithub.com/twstrike/ed448   0.051s

[Bug go/80914] gcc-go binaries don't run

2017-10-10 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

Ian Lance Taylor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from Ian Lance Taylor  ---
Thanks for figuring it out.  I committed a patch to the GCC 7 branch to ignore
compressed debug sections.  With this change many programs will work, but
programs that rely on runtime.Callers information will fail.

As you say, compressing debug sections should work fine in the GCC 8 release.

[Bug go/80914] gcc-go binaries don't run

2017-10-10 Thread ian at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #5 from ian at gcc dot gnu.org  ---
Author: ian
Date: Tue Oct 10 16:55:04 2017
New Revision: 253594

URL: https://gcc.gnu.org/viewcvs?rev=253594&root=gcc&view=rev
Log:
PR go/80914
* elf.c (SHF_COMPRESSED): Define.
(elf_add): Ignore debug sections with SHF_COMPRESSED set.

Modified:
branches/gcc-7-branch/libbacktrace/ChangeLog
branches/gcc-7-branch/libbacktrace/elf.c

[Bug go/80914] gcc-go binaries don't run

2017-10-10 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #4 from Steven Noonan  ---
This bug is still present, but I believe I know what is causing this.

At the time I reported this, I was using a binutils configured with
--enable-compressed-debug-sections=all. The resulting go.gcc binary just
crashed when run.

If I build GCC using a binutils configured with
--enable-compressed-debug-sections=none instead, then the resulting go.gcc runs
fine:

$ go.gcc version
go version go1.8.3 gccgo (GCC) 7.2.1 20171005 linux/amd64

I see that libbacktrace was made to support compressed debug sections in trunk
only very recently:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67165

So while it's likely unreasonable to ask that this be ported over into 7.2.x,
could some work be done to make libbacktrace fail more gracefully if GCC is
built without compressed debug section support enabled?

[Bug go/80914] gcc-go binaries don't run

2017-05-30 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #3 from Steven Noonan  ---
This is from a different go.gcc binary, because I've rebuilt several times to
try and troubleshoot. But this one still exhibits the bad behavior. Just in
case, I've uploaded a copy of the binary, the entire 'readelf --debug=info'
output, and the current gdb output:

https://www.uplinklabs.net/files/gcc-pr80914/gcc-go-debug-info.txt
https://www.uplinklabs.net/files/gcc-pr80914/gdb.txt
https://www.uplinklabs.net/files/gcc-pr80914/go.gcc.gz


Here's 'tail -n 30' of the gcc-go-debug-info.txt from above:

<2338a>   DW_AT_location: 2 byte block: 91 60   (DW_OP_fbreg: -32)  
 <2><2338d>: Abbrev Number: 0   
 <1><2338e>: Abbrev Number: 7 (DW_TAG_pointer_type) 
<2338f>   DW_AT_byte_size   : 8 
<23390>   DW_AT_type: <0x22f27> 
 <1><23394>: Abbrev Number: 43 (DW_TAG_subprogram)  
<23395>   DW_AT_name: (indirect string, offset: 0x32231):
base_of_encoded_value  
<23399>   DW_AT_decl_file   : 1 
<2339a>   DW_AT_decl_line   : 101   
<2339b>   DW_AT_prototyped  : 1 
<2339b>   DW_AT_type: <0x22e30> 
<2339f>   DW_AT_low_pc  : 0x4bc54a  
<233a7>   DW_AT_high_pc : 0x83  
<233af>   DW_AT_frame_base  : 1 byte block: 9c  (DW_OP_call_frame_cfa)  
<233b1>   DW_AT_GNU_all_tail_call_sites: 1
 <2><233b1>: Abbrev Number: 28 (DW_TAG_formal_parameter)
<233b2>   DW_AT_name: (indirect string, offset: 0x3216f): encoding
<233b6>   DW_AT_decl_file   : 1
<233b7>   DW_AT_decl_line   : 101
<233b8>   DW_AT_type: <0x22a32>
<233bc>   DW_AT_location: 2 byte block: 91 6c   (DW_OP_fbreg: -20)
 <2><233bf>: Abbrev Number: 28 (DW_TAG_formal_parameter)
<233c0>   DW_AT_name: (indirect string, offset: 0x21373): context
<233c4>   DW_AT_decl_file   : 1
<233c5>   DW_AT_decl_line   : 101
<233c6>   DW_AT_type: <0x22f10>
<233ca>   DW_AT_location: 2 byte block: 91 60   (DW_OP_fbreg: -32)
 <2><233cd>: Abbrev Number: 0
 <1><233ce>: Abbrev Number: 0

[Bug go/80914] gcc-go binaries don't run

2017-05-30 Thread ian at airs dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #2 from Ian Lance Taylor  ---
The failure is in libbacktrace.  The program crashes because once libbacktrace
fails the first time, the program is trying to use libbacktrace to show a stack
trace of the failure.  This leads to an infinite recursion that blows out the
stack.

libbacktrace appears to be failing because it finds a compilation unit in the
.debug_info section with length 1.  That doesn't leave enough space for the two
byte version number at the start of the compilation unit.  I don't understand
why this would be.

The failure appears to be at the end of the .debug_info section.  Can you run
`readelf --debug=info` on your executable, and attach the last thirty lines or
so?  Thanks.

[Bug go/80914] gcc-go binaries don't run

2017-05-29 Thread steven at uplinklabs dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80914

--- Comment #1 from Steven Noonan  ---
Possibly better backtrace from an -O0 -g build of GCC:

Program received signal SIGSEGV, Segmentation fault.
0x7731307e in __generic_morestack (pframe_size=0x77fa3050,
old_stack=0x77fa3070, param_size=0) at
/build/gcc-multilib/src/gcc/libgcc/generic-morestack.c:573
573 /build/gcc-multilib/src/gcc/libgcc/generic-morestack.c: No such file or
directory.
(gdb) bt full
#0  0x7731307e in __generic_morestack (pframe_size=0x77fa3050,
old_stack=0x77fa3070, param_size=0) at
/build/gcc-multilib/src/gcc/libgcc/generic-morestack.c:573
frame_size = 1576
current = 0x77313ef3 <__morestack+47>
pp = 0x77fa3008
dynamic = 0x0
from = 0xa3c13bd723171300 
to = 0x0
ret = 0x0
i = 4
aligned = 0
#1  0x77313ef3 in __morestack () at
/build/gcc-multilib/src/gcc/libgcc/config/i386/morestack.S:510
No locals.
#2  0x772fb590 in dwarf_buf_error (buf=0x77fa32b0,
msg=0x774b71ef "DWARF underflow") at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:380
b = "DWARF underflow in .debug_info at 4", '\000' 
#3  0x772fb5ea in require (buf=0x77fa32b0, count=2) at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:394
No locals.
#4  0x772fb61f in advance (buf=0x77fa32b0, count=2) at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:407
No locals.
#5  0x772fb708 in read_uint16 (buf=0x77fa32b0) at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:445
p = 0x77e386cb ""
#6  0x772fd8b1 in build_address_map (state=0x77fa7000,
base_address=0, dwarf_info=0x77e386c7 "\001", dwarf_info_size=70042,
dwarf_abbrev=0x77e49861 "\001", dwarf_abbrev_size=1206,
dwarf_ranges=0x77e6770a "\001", dwarf_ranges_size=458,
dwarf_str=0x77e5155a "\001", dwarf_str_size=90544, is_bigendian=0,
error_callback=0x76e6ec32 , data=0x77fa3cd0,
addrs=0x77fa33d0) at /build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:1461
len = 1
unit_buf = {
  name = 0x774b72f7 ".debug_info", 
  start = 0x77e386c7 "\001", 
  buf = 0x77e386cb "", 
  left = 1, 
  is_bigendian = 0, 
  error_callback = 0x76e6ec32 , 
  data = 0x77fa3cd0, 
  reported_underflow = 0
}
addrsize = 32767
u = 0x77e78c08
unit_data_start = 0x77e386c7 "\001"
is_dwarf64 = 0
version = -147843478
abbrev_offset = 0
info = {
  name = 0x774b72f7 ".debug_info", 
  start = 0x77e386c7 "\001", 
  buf = 0x77e386cc "", 
  left = 70037, 
  is_bigendian = 0, 
  error_callback = 0x76e6ec32 , 
  data = 0x77fa3cd0, 
  reported_underflow = 0
}
abbrevs = {
  num_abbrevs = 0, 
  abbrevs = 0x0
}
#7  0x77300c75 in build_dwarf_data (state=0x77fa7000,
base_address=0, dwarf_info=0x77e386c7 "\001", dwarf_info_size=70042,
dwarf_line=0x77e49d17 "\001", dwarf_line_size=30787,
dwarf_abbrev=0x77e49861 "\001", dwarf_abbrev_size=1206,
dwarf_ranges=0x77e6770a "\001", dwarf_ranges_size=458,
dwarf_str=0x77e5155a "\001", dwarf_str_size=90544, is_bigendian=0,
error_callback=0x76e6ec32 , data=0x77fa3cd0) at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:2932
addrs_vec = {
  vec = {
base = 0x0, 
size = 0, 
alc = 0
  }, 
  count = 0
}
addrs = 0x18
addrs_count = 140737353757712
fdata = 0x773016c7 
#8  0x77300e46 in backtrace_dwarf_add (state=0x77fa7000,
base_address=0, dwarf_info=0x77e386c7 "\001", dwarf_info_size=70042,
dwarf_line=0x77e49d17 "\001", dwarf_line_size=30787,
dwarf_abbrev=0x77e49861 "\001", dwarf_abbrev_size=1206,
dwarf_ranges=0x77e6770a "\001", dwarf_ranges_size=458,
dwarf_str=0x77e5155a "\001", dwarf_str_size=90544, is_bigendian=0,
error_callback=0x76e6ec32 , data=0x77fa3cd0,
fileline_fn=0x77fa3810) at
/build/gcc-multilib/src/gcc/libbacktrace/dwarf.c:2992
fdata = 0x77fa3cd0
#9  0x77302d07 in elf_add (state=0x77fa7000, descriptor=-1,
base_address=0, error_callback=0x76e6ec32 ,
data=0x77fa3cd0, fileline_fn=0x77fa3810, found_sym=0x77fa3804,
found_dwarf=0x77fa3808, exe=1) at
/build/gcc-multilib/src/gcc/libbacktrace/elf.c:817
ehdr_view = {
  data = 0x77fa1000, 
  base = 0x77fa1000, 
  len = 4096
}
ehdr = {
  e_ident = "\177ELF\002\001\001\000\000\000\000\000\000\000\000", 
  e_type = 2, 
  e_machine = 62, 
  e_version = 1, 
  e_entry = 4258992, 
  e_phoff = 64, 
  e_shoff = 1621392, 
  e_flags = 0, 
  e_ehsiz