Bug 14663 – shared library test - link_linkdep - segfaults on FreeBSD 10
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
FreeBSD
Creation time
2015-06-08T04:09:00Z
Last change time
2017-07-22T12:36:13Z
Keywords
pull
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2015-06-08T04:09:40Z
Running the druntime unit tests with the current dmd/druntime master (post 2.067) on FreeBSD 10 results in
Testing link
Testing load
Testing linkD
Testing linkDR
Testing loadDR
Testing host
Testing finalize
Testing link_linkdep
Makefile:28: recipe for target 'obj/freebsd/64/link_linkdep.done' failed
gmake[1]: *** [obj/freebsd/64/link_linkdep.done] Segmentation fault
gmake[1]: Leaving directory '/usr/home/jmdavis/Programming/github/druntime/test/shared'
posix.mak:206: recipe for target 'test/shared/.run' failed
gmake: *** [test/shared/.run] Error 2
I don't know if FreeBSD 9 has the same problem, but clearly FreeBSD 8 does not, because that's what the autotester is running, and it's passing. So, something changed in either FreeBSD 9 or 10 to make it so that this test doesn't work anymore.
I'll see if I can figure something out, but I'm not at all familiar with how the shared library code works or what exactly is being tested.
Comment #1 by issues.dlang — 2015-07-06T10:08:06Z
issue# 14776 is likely related to this one, but I don't know if they're the same bug or not. issue# 14776 is only triggered without -release and stops the unit tests before they get to the link_linkdep test which this bug report is for.
Comment #2 by code — 2015-07-26T15:39:44Z
Can't reproduce the issue using dmd/druntime master and FBSD 10.
Comment #3 by code — 2015-07-26T15:47:13Z
Oh wait, it happens only when using gcc, both in debug and release builds.
Comment #4 by code — 2015-07-26T16:24:55Z
It dies in the runtime linker itself before _start and before library initialization. It's hard to find out b/c the runtime linker neither has symbols nor debug information. From a ktrace/utrace dump it seems that it happens shortly after relocation the symbols in liblinkdep.so https://github.com/freebsd/freebsd/blob/d16fdde7e16c8c6a2133a2385b83ce0955e576b1/libexec/rtld-elf/rtld.c#L2622.
Seems there is something wrong with linking segments.
When linked with clang it's:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000000006ec 0x00000000000006ec R E 200000
LOAD 0x00000000000006f0 0x00000000002006f0 0x00000000002006f0
0x00000000000002a8 0x00000000000002a8 RW 200000
DYNAMIC 0x0000000000000760 0x0000000000200760 0x0000000000200760
0x00000000000001d0 0x00000000000001d0 RW 8
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 8
Section to Segment mapping:
Segment Sections...
00 .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .eh_frame
01 .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .minfo
02 .dynamic
03
When linked with gcc it becomes:
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000200aa8 0x0000000000200ac0 RWE 200000
DYNAMIC 0x0000000000200830 0x0000000000200830 0x0000000000200830
0x0000000000000210 0x0000000000000210 RW 8
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 10
Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .eh_frame .init_array .fini_array .ctors .dtors .jcr .data.rel.ro .dynamic .got .got.plt .data .minfo .bss
01 .dynamic
02
For some reason the readonly segment get's merged with the writeable segment.
We had something similar already as issue 13117.
(In reply to Martin Nowak from comment #3)
> Oh wait, it happens only when using gcc, both in debug and release builds.
I wasn't aware that you could use anything other than gcc. dmd spits out errors if gcc isn't available for it to use.
Comment #7 by code — 2015-07-28T18:23:21Z
(In reply to Jonathan M Davis from comment #6)
> I wasn't aware that you could use anything other than gcc. dmd spits out
> errors if gcc isn't available for it to use.
I just fixed dmd's makefile, simply set CC.
https://github.com/D-Programming-Language/dmd/pull/4837
Comment #8 by github-bugzilla — 2015-08-19T12:00:41Z