Skip to content

Instantly share code, notes, and snippets.

@shirosaki
Created September 19, 2012 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirosaki/3748627 to your computer and use it in GitHub Desktop.
Save shirosaki/3748627 to your computer and use it in GitHub Desktop.
ld crash on XP backtrace

My Build uses the following sources:

binutils-2.22.tar.bz2
cloog-0.17.0.tar.gz
expat-2.1.0.tar.gz
gcc-4.7.1.tar.bz2
gdb-7.5.tar.gz
gmp-5.0.5.tar.bz2
isl-0.10.tar.bz2
libiconv-1.14.tar.gz
make-3.82.tar.gz
mingw-w64-v2.0.6.tar.gz
mpc-1.0.1.tar.gz
mpfr-3.1.1.tar.bz2
ppl-1.0.tar.gz
winpthreads Revision: 5396

Build on CentOS release 5.3 (Final) x86 with gcc version 4.4.4 20100726 (Red Hat 4.4.4-13).

My build works fine. But replacing binutils with ruben's source (2.23.51.20120816) causes ld crash on XP. I got the source from gcc-4.7.1-2-release_rubenvb.tar.xz.

Compiling binutils with debug option (-g), I got the following back trace.

sh-3.1$ gdb --args ld -shared -s --enable-auto-image-base --enable-auto-import
--out-implib=libmsvcrt-ruby200.dll.a msvcrt-ruby200.def --stack 0x00200000 --en
able-auto-import   dln.o encoding.o version.o array.o bignum.o class.o compar.o
 complex.o dir.o dln_find.o enum.o enumerator.o error.o eval.o load.o proc.o fi
le.o gc.o hash.o inits.o io.o marshal.o math.o node.o numeric.o object.o pack.o
 parse.o process.o random.o range.o rational.o re.o regcomp.o regenc.o regerror
.o regexec.o regparse.o regsyntax.o ruby.o safe.o signal.o sprintf.o st.o strft
ime.o string.o struct.o time.o transcode.o util.o variable.o compile.o debug.o
iseq.o vm.o vm_dump.o vm_backtrace.o vm_trace.o thread.o cont.o ascii.o us_asci
i.o unicode.o utf_8.o newline.o langinfo.o fileblocks.o crypt.o lgamma_r.o strl
cpy.o strlcat.o ffs.o setproctitle.o win32/win32.o win32/file.o  prelude.o dmye
xt.o msvcrt-ruby200.res.o -lshell32 -lws2_32 -limagehlp -lshlwapi -L/c/WINDOWS/
system32   -o msvcrt-ruby200.dll
GNU gdb (rubenvb-4.7.1) 7.5
Copyright (C) 2012 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 "i686-w64-mingw32".
For bug reporting instructions, please see:
<mingw-w64-public@lists.sourceforge.net>...
Reading symbols from C:\devruby\rubyinstaller\sandbox\devkit\mingw\bin\ld.exe...
done.
(gdb) r
Starting program: C:\devruby\rubyinstaller\sandbox\devkit\mingw\bin\ld.exe -shar
ed -s --enable-auto-image-base --enable-auto-import "--out-implib=libmsvcrt-ruby
200.dll.a" msvcrt-ruby200.def --stack 0x00200000 --enable-auto-import dln.o enco
ding.o version.o array.o bignum.o class.o compar.o complex.o dir.o dln_find.o en
um.o enumerator.o error.o eval.o load.o proc.o file.o gc.o hash.o inits.o io.o m
arshal.o math.o node.o numeric.o object.o pack.o parse.o process.o random.o rang
e.o rational.o re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax
.o ruby.o safe.o signal.o sprintf.o st.o strftime.o string.o struct.o time.o tra
nscode.o util.o variable.o compile.o debug.o iseq.o vm.o vm_dump.o vm_backtrace.
o vm_trace.o thread.o cont.o ascii.o us_ascii.o unicode.o utf_8.o newline.o lang
info.o fileblocks.o crypt.o lgamma_r.o strlcpy.o strlcat.o ffs.o setproctitle.o
win32/win32.o win32/file.o prelude.o dmyext.o msvcrt-ruby200.res.o -lshell32 -lw
s2_32 -limagehlp -lshlwapi -Lc:/WINDOWS/system32 -o msvcrt-ruby200.dll
[New Thread 1680.0xd9c]
Warning: resolving ___WSAFDIsSet@8 by linking to ___WSAFDIsSet
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Cannot export _stricmp: symbol not defined
Cannot export _strnicmp: symbol not defined

Program received signal SIGSEGV, Segmentation fault.
0x004a04b6 in htab_find_slot (htab=htab@entry=0xfeeefeee,
    element=element@entry=0x182fd10, insert=insert@entry=NO_INSERT)
    at /home/shirosaki/mingw-w64/src/binutils/libiberty/hashtab.c:712
712     /home/shirosaki/mingw-w64/src/binutils/libiberty/hashtab.c: No such file
 or directory.
(gdb) bt
#0  0x004a04b6 in htab_find_slot (htab=htab@entry=0xfeeefeee,
    element=element@entry=0x182fd10, insert=insert@entry=NO_INSERT)
    at /home/shirosaki/mingw-w64/src/binutils/libiberty/hashtab.c:712
#1  0x004359db in _bfd_archive_close_and_cleanup (abfd=0x4337388)
    at /home/shirosaki/mingw-w64/src/binutils/bfd/archive.c:2740
#2  0x0043620a in bfd_close (abfd=abfd@entry=0x4337388)
    at /home/shirosaki/mingw-w64/src/binutils/bfd/opncls.c:718
#3  0x00425f19 in pe_dll_generate_implib (def=0x1c4d460,
    impfilename=0x38628 "libmsvcrt-ruby200.dll.a", info=0x5d60a0)
    at /home/shirosaki/mingw-w64/src/binutils/ld/pe-dll.c:2817
#4  0x0041d8e4 in gld_i386pe_finish () at ei386pe.c:1766
#5  0x00412591 in lang_process ()
    at /home/shirosaki/mingw-w64/src/binutils/ld/ldlang.c:6791
#6  0x004c5427 in main (argc=95, argv=0x32bf0)
    at /home/shirosaki/mingw-w64/src/binutils/ld/ldmain.c:411
(gdb) p htab
$1 = (htab_t) 0xfeeefeee
(gdb) p *htab
Cannot access memory at address 0xfeeefeee

htab seems not valid value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment