October 05, 2020
https://issues.dlang.org/show_bug.cgi?id=21293

          Issue ID: 21293
           Summary: cxx-headers-test build target segfaults
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: doob@me.com

Running `./src/build.d cxx-headers-test` results in a segmentation fault on macOS. Is the invocation of DMD that fails. Running the DMD command (which is printed when `./src/build.d cxx-headers-test`) inside a debugger results in this stacktrace:

(lldb) r
Process 40315 launched: 'dlang/dmd/generated/osx/release/64/dmd' (x86_64)
Process 40315 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
    frame #0: 0x000000010012b43c
dmd`_D3dmd4root5array__T5ArrayTCQBa7dsymbol7DsymbolZQBc7opSliceMNgFNaNbNiNfZANgCQCwQBwQBr
at array.d:305
   302
   303      extern (D) inout(T)[] opSlice() inout nothrow pure @nogc
   304      {
-> 305          return data[0 .. length];
   306      }
   307
   308      extern (D) inout(T)[] opSlice(size_t a, size_t b) inout nothrow
pure @nogc
Target 0: (dmd) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS
(code=1, address=0x0)
  * frame #0: 0x000000010012b43c
dmd`_D3dmd4root5array__T5ArrayTCQBa7dsymbol7DsymbolZQBc7opSliceMNgFNaNbNiNfZANgCQCwQBwQBr
at array.d:305
    frame #1: 0x00000001000bb603 dmd`ToCppBuffer::visit(EnumDeclaration*) at
dtoh.d:1252
    frame #2: 0x000000010005044a dmd`EnumDeclaration::accept(Visitor*) at
denum.d:367
    frame #3: 0x00000001000bc395 dmd`ToCppBuffer::visit(TypeEnum*) at
dtoh.d:1497
    frame #4: 0x000000010017349a dmd`TypeEnum::accept(Visitor*) at mtype.d:6241
    frame #5: 0x00000001000bcfe7 dmd`ToCppBuffer::funcToBuffer(TypeFunction*,
FuncDeclaration*) at dtoh.d:1734
    frame #6: 0x00000001000b9432 dmd`ToCppBuffer::visit(FuncDeclaration*) at
dtoh.d:579
    frame #7: 0x0000000100103e1a dmd`FuncDeclaration::accept(Visitor*) at
func.d:2569
    frame #8: 0x00000001000bb1e3 dmd`ToCppBuffer::visit(ClassDeclaration*) at
dtoh.d:1157
    frame #9: 0x000000010004a1aa dmd`ClassDeclaration::accept(Visitor*) at
dclass.d:982
    frame #10: 0x00000001000badd7 dmd`ToCppBuffer::includeSymbol(Dsymbol*) at
dtoh.d:1095
    frame #11: 0x00000001000bb0b0 dmd`ToCppBuffer::visit(ClassDeclaration*) at
dtoh.d:1136
    frame #12: 0x000000010004a1aa dmd`ClassDeclaration::accept(Visitor*) at
dclass.d:982
    frame #13: 0x00000001000badd7 dmd`ToCppBuffer::includeSymbol(Dsymbol*) at
dtoh.d:1095
    frame #14: 0x00000001000bb0b0 dmd`ToCppBuffer::visit(ClassDeclaration*) at
dtoh.d:1136
    frame #15: 0x000000010004a1aa dmd`ClassDeclaration::accept(Visitor*) at
dclass.d:982
    frame #16: 0x00000001000b8e6c dmd`ToCppBuffer::visit(AttribDeclaration*) at
dtoh.d:456
    frame #17: 0x00000001001a209f
dmd`ParseTimeVisitor<ASTCodegen>::visit(StorageClassDeclaration*) at
parsetimevisitor.d:77
    frame #18: 0x00000001000137d2 dmd`StorageClassDeclaration::accept(Visitor*)
at attrib.d:324
    frame #19: 0x00000001000b8e6c dmd`ToCppBuffer::visit(AttribDeclaration*) at
dtoh.d:456
    frame #20: 0x00000001000b8f10 dmd`ToCppBuffer::visit(LinkDeclaration*) at
dtoh.d:479
    frame #21: 0x0000000100013ae2 dmd`LinkDeclaration::accept(Visitor*) at
attrib.d:432
    frame #22: 0x00000001000b8fe0 dmd`ToCppBuffer::visit(Module*) at dtoh.d:503
    frame #23: 0x00000001000704ca dmd`Module::accept(Visitor*) at
dmodule.d:1485
    frame #24: 0x00000001000b86ab dmd`genCppHdrFiles(Array<Module*>&) at
dtoh.d:245
    frame #25: 0x000000010015e17b
dmd`_D3dmd4mars7tryMainFmPPxaKSQz7globals5ParamZi at mars.d:674
    frame #26: 0x000000010015f1e5 dmd`_Dmain at mars.d:972
    frame #27: 0x000000010031e837
dmd`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZ9__lambda1MFZv + 31
    frame #28: 0x000000010031e6e1
dmd`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ7tryExecMFMDFZvZv + 33
    frame #29: 0x000000010031e7bb
dmd`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 139
    frame #30: 0x000000010031e6e1
dmd`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ7tryExecMFMDFZvZv + 33
    frame #31: 0x000000010031e64a dmd`_d_run_main2 + 626
    frame #32: 0x000000010031e3c2 dmd`_d_run_main + 190
    frame #33: 0x0000000100004360 dmd`main at mars.d:925
    frame #34: 0x00007fff71f31cc9 libdyld.dylib`start + 1

--