#750947 /usr/bin/ld.bfd: /usr/bin/ld: ld.bfd works and __then__ segfaults

Package:
binutils
Source:
binutils
Description:
GNU assembler, linker and binary utilities
Submitter:
Lorenzo Beretta
Date:
2014-12-11 16:57:18 UTC
Severity:
important
#750947#5
Date:
2014-06-08 19:13:51 UTC
From:
To:
Dear Maintainer,


/usr/bin/ld.bfd crashes after it's done linking
(while cleaning up its own memory?); /usr/bin/ld.gold works.
$ script

Script started on Sun 08 Jun 2014 08:46:38 PM CEST
$ cat>x.c <<EOF
	int main  () { return 0; }
	EOF
$ gcc x.c
collect2: error: ld terminated with signal 11 [Segmentation fault]
$ ./a.out # created ok, runs ok
$ gcc -c x.c
$ gcc -s c x.o
collect2: error: ld terminated with signal 11 [Segmentation fault]
$ ./a.out
$ gdb --args x.  gcc -d s x.0 o
GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1.1+b1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/gcc-4.8...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/gcc -s x.o
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
collect2: error: ld terminated with signal 11 [Segmentation fault]
[Inferior 1 (process 3742) exited with code 01]
(gdb) q
$ ls -l /usr/bin/ld*
lrwxrwxrwx 1 root root       6 Jun  7 13:53 /usr/bin/ld -> ld.bfd
-rwxr-xr-x 1 root root     394 Apr 25 21:48 /usr/bin/ld-musl-config
-rwxr-xr-x 1 root root 1047648 Jun  7 13:53 /usr/bin/ld.bfd
-rwxr-xr-x 1 root root 2502432 Jun  7 13:53 /usr/bin/ld.gold
-rwxr-xr-x 1 root root    5388 Jun  4 22:27 /usr/bin/ldd
$ ld.   gdb --args ld.bfd x.o
GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1.1+b1)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/ld.bfd...(no debugging symbols found)...done.
(gdb) r
Starting program: /usr/bin/ld.bfd x.o
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
/usr/bin/ld.bfd: warning: cannot find entry symbol _start; defaulting to 00000000004000b0

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b003e4 in bfd_hash_table_free () from /usr/lib/libbfd-2.24.51-system.20140604.so
(gdb) q
A debugging session is active.

	Inferior 1 [process 3759] will be killed.

Quit anyway? (y or n) y
$ ls d.gold x.o
$
Script done on Sun 08 Jun 2014 08:49:42 PM CEST


Probably not necessary because clang crashes in the exact same way,
but just in case:
$ gcc --version
gcc (Debian 4.8.3-3) 4.8.3
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#750947#10
Date:
2014-06-10 20:21:19 UTC
From:
To:
Some time ago I found out about MALLOC_PERTURB_, stuck it in my
~/.profile and forgot about it (am I really the only one using it?).


$ cat>r0.c <<EOF
int main() { return 0; }
EOF
$ gcc r0.c	# segmentation fault
$ env -u MALLOC_PERTURB_ gcc r0.c	# ok


The memory corruption is obviously still there and should be fixed, but
it's only visible if you turn on malloc debugging - I think you should
change the bug description to make it clear.


See you,
loreb.

#750947#15
Date:
2014-06-11 17:45:45 UTC
From:
To:
Hi,

I received reports about ld crashes leading to FTBFS of libguestfs
rebuilds. On amd64, i386, it crashed when building the Golang bindings,
on mipsel it crashed while linking the test-tool for "make quickcheck".

I have been able to reproduce both crashes on amd64, in both cases the
backtrace looked like this:

(gdb) bt
#0  0x00007f83281b03e4 in bfd_hash_table_free ()
   from /usr/lib/libbfd-2.24.51-system.20140604.so
#1  0x00007f83281ba6b9 in _bfd_merge_sections_free ()
   from /usr/lib/libbfd-2.24.51-system.20140604.so
#2  0x00007f83281e78c1 in _bfd_elf_link_hash_table_free ()
   from /usr/lib/libbfd-2.24.51-system.20140604.so
#3  0x000000000044725a in ?? ()
#4  0x00007f832823ec29 in xexit ()
   from /usr/lib/libbfd-2.24.51-system.20140604.so
#5  0x000000000040574c in ?? ()
#6  0x00007f83279bcb45 in __libc_start_main (main=0x405200, argc=51,
    argv=0x7fff256e7a28, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fff256e7a18) at libc-start.c:287
#7  0x0000000000405cda in ?? ()

Cheers,
-Hilko

#750947#25
Date:
2014-06-16 09:39:18 UTC
From:
To:
forwarded 750947 https://sourceware.org/bugzilla/show_bug.cgi?id=17047
thanks

Some time ago I got the same error when doing "make check" in gettext
and reported it to the upstream.  The current git master works fine.

Regards,
--
Daiki Ueno