D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15577 - -profile and atomicOp segfaults
Summary: -profile and atomicOp segfaults
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Mac OS X
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-18 08:04 UTC by Jacob Carlborg
Modified: 2022-10-28 10:34 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 Jacob Carlborg 2016-01-18 08:04:08 UTC
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
Comment 1 RazvanN 2022-10-28 10:34:27 UTC
I cannot reproduce this. The code successfully compiles and runs.