www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15577] New: -profile and atomicOp segfaults

https://issues.dlang.org/show_bug.cgi?id=15577

          Issue ID: 15577
           Summary: -profile and atomicOp segfaults
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: doob me.com

Compiling the following code with -profile. When running the binary it will
result in a segmentation fault. Seems to only happen when "foo" is ulong. It
occurs with DMD 2.070.0-b2 and several older versions.

import core.atomic;

shared ulong foo;

void main()
{
    atomicOp!"+="(foo, 1);
}

Debugger session:

$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) r
Process 97890 launched: '/Users/jacob/development/d/main' (x86_64)
Process 97890 stopped
* thread #1: tid = 0x20eb0a, 0x0000000100022e2e
main`D2rt12sections_osx9tlsOffsetFPvZm + 90, queue = 'com.apple.main-thread',
stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x0000000100022e2e main`D2rt12sections_osx9tlsOffsetFPvZm + 90
main`D2rt12sections_osx9tlsOffsetFPvZm:
->  0x100022e2e <+90>: hlt
    0x100022e2f <+91>: nop

main`sections_osx_onAddImage:
    0x100022e30 <+0>:  pushq  %rbp
    0x100022e31 <+1>:  movq   %rsp, %rbp
(lldb) bt
* thread #1: tid = 0x20eb0a, 0x0000000100022e2e
main`D2rt12sections_osx9tlsOffsetFPvZm + 90, queue = 'com.apple.main-thread',
stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x0000000100022e2e main`D2rt12sections_osx9tlsOffsetFPvZm + 90
    frame #1: 0x0000000100022ce9 main`__tls_get_addr + 29
    frame #2: 0x0000000100024679 main`trace_pro + 37
    frame #3: 0x0000000100001750
main`D4core6atomic24__T14atomicFetchAddTmTiZ14atomicFetchAddFNaNbNiKOmiZm + 44
at atomic.d:657
    frame #4: 0x000000010001e41d main`rt_init + 45
    frame #5: 0x000000010001e9ae
main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 14
    frame #6: 0x000000010001e960
main`D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 56
    frame #7: 0x000000010001e8b2 main`_d_run_main + 498
    frame #8: 0x000000010000168a main`main + 34
    frame #9: 0x00007fff8c7795c9 libdyld.dylib`start + 1
    frame #10: 0x00007fff8c7795c9 libdyld.dylib`start + 1

--
Jan 18