D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4185 - Existence of an empty, uncalled function that takes a TLS variable as its parameter generates segfaulting executable using DMD >= 2.044 and the GOLD linker.
Summary: Existence of an empty, uncalled function that takes a TLS variable as its par...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-13 17:01 UTC by Bernard Helyer
Modified: 2015-06-09 05:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bernard Helyer 2010-05-13 17:01:02 UTC
void* bar;
    void foo(void*) {}
    void baz() { foo(bar); }
    void main() {}

This code causes DMD to produce an executable that segfaults inside of GC.collect.

    (gdb) bt
    #0  0x08050aa2 in _D4core6thread17thread_suspendAllUZv7suspendMFC4core6thread6ThreadZv ()
    #1  0x08050a1b in thread_suspendAll ()
    #2  0x0804decd in _D2gc3gcx3Gcx11fullcollectMFPvZk ()
    #3  0x0804deae in _D2gc3gcx3Gcx16fullcollectshellMFZk ()
    #4  0x0804d115 in _D2gc3gcx2GC18fullCollectNoStackMFZv ()
    #5  0x0804bd20 in gc_term ()
    #6  0x0804a9b0 in _D2rt6dmain24mainUiPPaZi6runAllMFZv ()
    #7  0x0804a8b9 in _D2rt6dmain24mainUiPPaZi7tryExecMFMDFZvZv ()
    #8  0x0804a868 in main ()

However, in the course of boiling down a test case, the segfault has moved around with great regularity (inside of a library SO, inside of libc.exit, whilst appending to an array, the list goes on), so I'm speculating that it's some kind of memory corruption. 

This occurs on Linux using D2, neither D1 nor Windows using D1,D2 manifests this issue.
Comment 1 Bernard Helyer 2010-05-13 17:02:29 UTC
I forgot to say that this issue occurs when using DMD 2.044 and up.
Comment 2 Bernard Helyer 2010-05-14 03:58:06 UTC
If bar is declared as __gshared, the executable behaves correctly.
Comment 3 Steven Schveighoffer 2010-05-14 04:58:16 UTC
I can't reproduce this on Linux 2.045 and the current beta.  Can you try a clean install of the compiler?
Comment 4 Bernard Helyer 2010-05-14 05:07:13 UTC
Yep.

What arch are you on? How much memory do you have installed (myself == x86, 1.5 GiB). Like I said, I think this is memory corruption of some description, so it's bound to be nebulous.
Comment 5 Steven Schveighoffer 2010-05-14 05:10:31 UTC
I'm on x86 1 Gb.

What flags do you pass to the compiler?
Comment 6 Bernard Helyer 2010-05-14 05:13:33 UTC
None: dmd testmodule
Comment 7 Bernard Helyer 2010-05-14 05:14:16 UTC
Steve, could you run it in valgrind?
Comment 8 Bernard Helyer 2010-05-14 05:14:37 UTC
Steven, sorry. :o
Comment 9 Bernard Helyer 2010-05-14 23:14:52 UTC
Okay, this only occurs when the GNU GOLD linker is installed instead of the vanilla. This could be a bug in DMD, but it's probably GOLD, so closing this as INVALID.