Subject: port-mips/23366: Newly compiled mips c++ programs segfault during startup
To: None <>
From: None <>
List: netbsd-bugs
Date: 11/04/2003 10:30:01
>Number:         23366
>Category:       port-mips
>Synopsis:       Newly compiled mips c++ programs segfault during startup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-mips-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 04 09:38:00 UTC 2003
>Originator:     Havard Eidnes
>Release:        NetBSD 1.6ZE
System: NetBSD 1.6ZE NetBSD 1.6ZE (VIOLA) #8: Sun Oct 26 13:55:14 CET 2003 sgimips
Architecture: mipseb
Machine: sgimips
	A minimal c++ program bombs out with a segmentation fault before
	main() is called.

	This causes me to be unable to update my tools before the problem
	is fixed, as the groff configure script bombs out.


viola# cat t.c
int main() { return 0; }
viola# c++ t.c
viola# ./a.out
Segmentation fault (core dumped)

viola# c++ --version
c++ (GCC) 3.3.2 (NetBSD nb1 20031026)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

viola# ident /usr/libexec/ld.elf_so
     $NetBSD: strcmp.S,v 1.7 2003/08/07 16:42:16 agc Exp $
     $NetBSD: strlen.S,v 1.7 2003/08/07 16:42:16 agc Exp $
     $NetBSD: bcopy.S,v 1.9 2002/11/10 18:10:25 thorpej Exp $
     $NetBSD: bcopy.S,v 1.9 2002/11/10 18:10:25 thorpej Exp $
     $NetBSD: cerror.S,v 1.13 2003/08/07 16:42:17 agc Exp $
     $NetBSD: strspn.c,v 1.10 2003/08/07 16:43:52 agc Exp $
     $NetBSD: strcspn.c,v 1.10 2003/08/07 16:43:50 agc Exp $
     $NetBSD: strsep.c,v 1.14 2003/08/07 16:43:52 agc Exp $
     $NetBSD: rindex.c,v 1.13 2003/08/07 16:43:49 agc Exp $
     $NetBSD: strncpy.c,v 1.12 2003/08/07 16:43:51 agc Exp $
     $NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp $
     $NetBSD: exit.c,v 1.10 2003/08/07 16:43:39 agc Exp $
     $NetBSD: __errlist14.c,v 1.8 2003/08/07 16:42:45 agc Exp $
     $NetBSD: index.c,v 1.13 2003/08/07 16:43:48 agc Exp $
     $NetBSD: strcpy.c,v 1.13 2003/08/07 16:43:50 agc Exp $
     $NetBSD: memcmp.c,v 1.12 2003/08/07 16:43:48 agc Exp $
     $NetBSD: getenv.c,v 1.17 2003/08/07 16:43:39 agc Exp $
     $NetBSD: abort.c,v 1.12 2003/08/07 16:43:37 agc Exp $
     $NetBSD: signal.c,v 1.12 2003/08/07 16:42:56 agc Exp $
     $NetBSD: mmap.c,v 1.12 2003/08/07 16:44:02 agc Exp $
     $NetBSD: strncmp.c,v 1.13 2003/08/07 16:43:51 agc Exp $
     $NetBSD: sysctl.c,v 1.13 2003/08/07 16:42:57 agc Exp $
viola# ls -lL /usr/libexec/ld.elf_so
-r-xr-xr-x  1 root  wheel  72188 Oct 27 00:35 /usr/libexec/ld.elf_so*
viola# gdb a.out a.out.core
GNU gdb 5.3nb1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "mipseb--netbsd"...(no debugging symbols found)...
Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.elf_so...(no debugging symbols found)...
Loaded symbols for /usr/libexec/ld.elf_so
Reading symbols from /usr/lib/ debugging symbols found)...
Loaded symbols for /usr/lib/
Reading symbols from /usr/lib/ debugging symbols found)...done.
Loaded symbols for /usr/lib/
Reading symbols from /usr/lib/ debugging symbols found)...done.
Loaded symbols for /usr/lib/
#0  0x00002b80 in _rtld_relocate_nonplt_objects () from /usr/libexec/ld.elf_so
(gdb) where
#0  0x00002b80 in _rtld_relocate_nonplt_objects () from /usr/libexec/ld.elf_so
#1  0x00004980 in _rtld_relocate_objects () from /usr/libexec/ld.elf_so
#2  0x00003230 in _rtld () from /usr/libexec/ld.elf_so
(gdb) x/10i 0x2b70
0x2b70 <_rtld_relocate_nonplt_objects+528>:     lw      s0,32(sp)
0x2b74 <_rtld_relocate_nonplt_objects+532>:     jr      ra
0x2b78 <_rtld_relocate_nonplt_objects+536>:     addiu   sp,sp,64
0x2b7c <_rtld_relocate_nonplt_objects+540>:     lbu     t3,12(a0)
0x2b80 <_rtld_relocate_nonplt_objects+544>:     lw      a3,0(t2)
0x2b84 <_rtld_relocate_nonplt_objects+548>:     
    beq t3,a2,0x2b94 <_rtld_relocate_nonplt_objects+564>
0x2b88 <_rtld_relocate_nonplt_objects+552>:     nop
0x2b8c <_rtld_relocate_nonplt_objects+556>:     
    b   0x2b44 <_rtld_relocate_nonplt_objects+484>
0x2b90 <_rtld_relocate_nonplt_objects+560>:     addu    a3,a3,t1
0x2b94 <_rtld_relocate_nonplt_objects+564>:     
    bnez        s5,0x2b8c <_rtld_relocate_nonplt_objects+556>
(gdb) i regi
          zero       at       v0       v1       a0       a1       a2       a3
 R0   00000000 0004d030 00000000 00000012 30014800 0000000d 00000003 30097600 
            t0       t1       t2       t3       t4       t5       t6       t7
 R8   30035a80 d0030000 300dd546 00000003 30038ca8 300e6db0 00000003 30014730 
            s0       s1       s2       s3       s4       s5       s6       s7
 R16  600665e0 00000d03 600ad546 30003200 00000001 00000000 7fffe754 30003000 
            t8       t9       k0       k1       gp       sp       s8       ra
 R24  0000ff01 00009c78 00000000 00000000 00054a30 7fffe674 7fffe7dc 00002a84 
            sr       lo       hi      bad    cause       pc
      0004ff13 000099ef 00000793 300dd546 00000010 00002b80 
           fsr      fir       fp
      00000000 00000000 00000000 
(gdb) info target
Symbols from "/tmp/a.out".
Local core dump file:
        `/tmp/a.out.core', file type elf32-bigmips.
        0x0004c000 - 0x0004e000 is load2
        0x10000000 - 0x10001000 is load4
        0x30001000 - 0x30009000 is load6
        0x30010000 - 0x30099000 is load7
        0x300d8000 - 0x300e9000 is load9
        0x300e9000 - 0x300ed000 is load10
        0x30150000 - 0x30152000 is load13
        0x30276000 - 0x3027c000 is load16
        0x3027c000 - 0x3028a000 is load17
        0x7fffe000 - 0x7ffff000 is load18
        0x000000e0 - 0x000000f8 is .reginfo in /usr/libexec/ld.elf_so
        0x00000100 - 0x000001d8 is .dynamic in /usr/libexec/ld.elf_so
        0x000001e0 - 0x00000890 is .hash in /usr/libexec/ld.elf_so
        0x00000890 - 0x000016e0 is .dynsym in /usr/libexec/ld.elf_so
        0x000016e0 - 0x00002236 is .dynstr in /usr/libexec/ld.elf_so
        0x00002610 - 0x0000b5f0 is .text in /usr/libexec/ld.elf_so
        0x0000b5f0 - 0x0000c6e0 is .rodata in /usr/libexec/ld.elf_so
        0x0000c6e0 - 0x0000c6f8 is .note.netbsd.ident in /usr/libexec/ld.elf_so
        0x0004c700 - 0x0004ca40 is .data in /usr/libexec/ld.elf_so
        0x0004ca40 - 0x0004cdfc is .got in /usr/libexec/ld.elf_so
        0x0004cdfc - 0x0004ce30 is .sbss in /usr/libexec/ld.elf_so
        0x0004ce30 - 0x0004d7e0 is .bss in /usr/libexec/ld.elf_so
---Type <return> to continue, or q <return> to quit---
        0x00002240 - 0x00002610 is .rel.dyn in /usr/libexec/ld.elf_so
        0x300100e0 - 0x300100f8 is .reginfo in /usr/lib/
        0x30010100 - 0x300101e8 is .dynamic in /usr/lib/
        0x300101f0 - 0x30014724 is .hash in /usr/lib/
        0x30014730 - 0x3001db90 is .dynsym in /usr/lib/
        0x3001db90 - 0x3003380d is .dynstr in /usr/lib/
        0x30038ca8 - 0x30038d38 is .init in /usr/lib/
        0x30038d40 - 0x30096550 is .text in /usr/lib/
        0x30096550 - 0x300965e0 is .fini in /usr/lib/
        0x300965e0 - 0x300988b4 is .rodata in /usr/lib/
        0x300988b4 - 0x300988cc is .note.netbsd.ident in /usr/lib/
        0x300d88d0 - 0x300da8e0 is .data in /usr/lib/
        0x300da8e0 - 0x300e3d40 is .eh_frame in /usr/lib/
        0x300e3d40 - 0x300e6d80 is .gcc_except_table in /usr/lib/
        0x300e6d80 - 0x300e6d9c is .ctors in /usr/lib/
        0x300e6d9c - 0x300e6dac is .dtors in /usr/lib/
        0x300e6dac - 0x300e6db0 is .jcr in /usr/lib/
        0x300e6db0 - 0x300e80cc is .got in /usr/lib/
        0x300e80d0 - 0x300e8174 is .sbss in /usr/lib/
        0x300e8180 - 0x300ecdf0 is .bss in /usr/lib/
        0x30033810 - 0x30038ca8 is .rel.dyn in /usr/lib/
        0x300f00e0 - 0x300f00f8 is .reginfo in /usr/lib/
---Type <return> to continue, or q <return> to quit---
        0x300f0100 - 0x300f01e8 is .dynamic in /usr/lib/
        0x300f01f0 - 0x300f0864 is .hash in /usr/lib/
        0x300f0870 - 0x300f15d0 is .dynsym in /usr/lib/
        0x300f15d0 - 0x300f1bba is .dynstr in /usr/lib/
        0x300f1bd0 - 0x300f1c60 is .init in /usr/lib/
        0x300f1c60 - 0x3010d2a0 is .text in /usr/lib/
        0x3010d2a0 - 0x3010d330 is .fini in /usr/lib/
        0x3010d330 - 0x30110e78 is .rodata in /usr/lib/
        0x30110e78 - 0x30110e90 is .note.netbsd.ident in /usr/lib/
        0x30150e90 - 0x30150eb0 is .data in /usr/lib/
        0x30150eb0 - 0x30150eb4 is .eh_frame in /usr/lib/
        0x30150eb4 - 0x30150ebc is .ctors in /usr/lib/
        0x30150ebc - 0x30150ec4 is .dtors in /usr/lib/
        0x30150ec4 - 0x30150ec8 is .jcr in /usr/lib/
        0x30150ed0 - 0x30151084 is .got in /usr/lib/
        0x30151090 - 0x301510d0 is .bss in /usr/lib/
        0x300f1bc0 - 0x300f1bd0 is .rel.dyn in /usr/lib/
        0x301580e0 - 0x301580f8 is .reginfo in /usr/lib/
        0x30158100 - 0x301581e8 is .dynamic in /usr/lib/
        0x301581f0 - 0x3015c880 is .hash in /usr/lib/
        0x3015c880 - 0x30166250 is .dynsym in /usr/lib/
        0x30166250 - 0x3016b0e8 is .dynstr in /usr/lib/
        0x3016d468 - 0x3016d4f8 is .init in /usr/lib/
---Type <return> to continue, or q <return> to quit---
        0x3016d500 - 0x3022b770 is .text in /usr/lib/
        0x3022b770 - 0x3022b800 is .fini in /usr/lib/
        0x3022b800 - 0x302369d0 is .rodata in /usr/lib/
        0x302369d0 - 0x302369e8 is .note.netbsd.ident in /usr/lib/
        0x302769f0 - 0x3027ada0 is .data in /usr/lib/
        0x3027ada0 - 0x3027ada4 is .eh_frame in /usr/lib/
        0x3027ada4 - 0x3027adac is .ctors in /usr/lib/
        0x3027adac - 0x3027adb4 is .dtors in /usr/lib/
        0x3027adb4 - 0x3027adb8 is .jcr in /usr/lib/
        0x3027adc0 - 0x3027bd4c is .got in /usr/lib/
        0x3027bd4c - 0x3027bdd4 is .sbss in /usr/lib/
        0x3027bde0 - 0x30289ba0 is .bss in /usr/lib/
        0x3016b0f0 - 0x3016d468 is .rel.dyn in /usr/lib/
Local exec file:
        `/tmp/a.out', file type elf32-bigmips.
        Entry point: 0x400b30
        0x00400114 - 0x0040012b is .interp
        0x0040012c - 0x00400144 is .note.netbsd.ident
        0x00400150 - 0x00400168 is .reginfo
        0x00400170 - 0x00400268 is .dynamic
        0x00400270 - 0x004003e8 is .hash
        0x004003f0 - 0x00400760 is .dynsym
        0x00400760 - 0x00400a9f is .dynstr
        0x00400aa0 - 0x00400b30 is .init
---Type <return> to continue, or q <return> to quit---
        0x00400b30 - 0x00406760 is .text
        0x00406760 - 0x004067f0 is .fini
        0x004067f0 - 0x00406c20 is .rodata
        0x10000000 - 0x10000060 is .data
        0x10000060 - 0x10000064 is .rld_map
        0x10000064 - 0x1000066c is .eh_frame
        0x1000066c - 0x10000674 is .ctors
        0x10000674 - 0x1000067c is .dtors
        0x1000067c - 0x10000680 is .jcr
        0x10000680 - 0x10000720 is .got
        0x10000720 - 0x10000724 is .sbss
        0x10000730 - 0x10000840 is .bss

	a0 (0x30014800) apparently points somewhere into
        0x300f0870 - 0x300f15d0 is .dynsym in /usr/lib/

	while t2 (0x300dd546) points somewhere into
        0x300da8e0 - 0x300e3d40 is .eh_frame in /usr/lib/ why does it get a segmentation fault?!?

	Sorry, don't know.