[Issue 23006] New: importC: dmd segfaults on static initializer for multi-dimensional array inside struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 10 10:06:09 UTC 2022


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

          Issue ID: 23006
           Summary: importC: dmd segfaults on static initializer for
                    multi-dimensional array inside struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice-on-valid-code, ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: duser at neet.fi
                CC: duser at neet.fi

//int x[1][1] = {{1}}; // works
struct { int x[1][1]; } y = { {{1}} };

---
Program received signal SIGSEGV, Segmentation fault.
0x0000555555822310 in structs (this=0x7fffffffcf10, ts=0x7ffff6d5a900) at
src/dmd/initsem.d:699
699                     if (ex.op == EXP.error)
(gdb) i lo
vd = 0x7ffff757f8f0
ex = 0x0
iz = 0x7ffff757fb60
tm = 0x7ffff757f7d0
di = {designatorList = 0x0, initializer = 0x7ffff757fb60}
fieldi = 0
ie = 0x7fffffffce60
sle = 0x555555ab02c5 <OutBuffer::~OutBuffer()+24>
tx = 0x7ffff6d5a900
elems = {0x0}
elements = 0x7ffff6d5b040
nfields = 1
sd = 0x7ffff6d5a6f0
(gdb) bt
#0  0x0000555555822310 in structs (this=0x7fffffffcf10, ts=0x7ffff6d5a900) at
src/dmd/initsem.d:699
#1  0x0000555555821709 in visitC (this=0x7fffffffd020, ci=0x7ffff757fbc0) at
src/dmd/initsem.d:722
#2  0x0000555555735372 in initializerSemantic(Initializer*, Scope*, Type*&,
NeedInterpret) (init=0x7ffff757fbc0, sc=0x7ffff6d5a5a0, tx=@0x7ffff757fc80:
0x7ffff6d5a900, needInterpret=dmd.init.NeedInterpret.INITinterpret) at
src/dmd/initsem.d:926
#3  0x0000555555781817 in DsymbolSemanticVisitor::visit(VarDeclaration*)
(this=0x7fffffffd3b0, dsym=0x7ffff757fc20) at src/dmd/dsymbolsem.d:1143
#4  0x0000555555689bdc in VarDeclaration::accept(Visitor*)
(this=0x7ffff757fc20, v=0x7fffffffd3b0) at src/dmd/declaration.d:1653
#5  0x00005555556c84fb in dsymbolSemantic(Dsymbol*, Scope*)
(dsym=0x7ffff757fc20, sc=0x7ffff6d5a350) at src/dmd/dsymbolsem.d:105
#6  0x000055555578d2c0 in
DsymbolSemanticVisitor::attribSemantic(AttribDeclaration*)
(this=0x7fffffffd4a0, ad=0x7ffff757fd50) at src/dmd/dsymbolsem.d:1432
#7  0x000055555577cb96 in DsymbolSemanticVisitor::visit(AttribDeclaration*)
(this=0x7fffffffd4a0, atd=0x7ffff757fd50) at src/dmd/dsymbolsem.d:1444
#8  0x00005555558d14e6 in ParseTimeVisitor<ASTCodegen>::visit(LinkDeclaration*)
(this=0x7fffffffd4a0, s=0x7ffff757fd50) at src/dmd/parsetimevisitor.d:71
#9  0x000055555568a15c in LinkDeclaration::accept(Visitor*)
(this=0x7ffff757fd50, v=0x7fffffffd4a0) at src/dmd/attrib.d:434
#10 0x00005555556c84fb in dsymbolSemantic(Dsymbol*, Scope*)
(dsym=0x7ffff757fd50, sc=0x7ffff757ffb0) at src/dmd/dsymbolsem.d:105
#11 0x000055555578e3f9 in DsymbolSemanticVisitor.__lambda2
(this=0x7fffffffd550, s=0x7ffff757fd50) at src/dmd/dsymbolsem.d:1995
#12 0x00005555556e26d8 in
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
scope void(dmd.dsymbol.Dsymbol) delegate) (symbols=0x7ffff757fd30, dg=...) at
src/dmd/dsymbol.d:105
#13 0x00005555557860e0 in DsymbolSemanticVisitor::visit(Module*)
(this=0x7fffffffd5d0, m=0x7ffff757f4e0) at src/dmd/dsymbolsem.d:1992
#14 0x000055555569a387 in Module::accept(Visitor*) (this=0x7ffff757f4e0,
v=0x7fffffffd5d0) at src/dmd/dmodule.d:1450
#15 0x00005555556c84fb in dsymbolSemantic(Dsymbol*, Scope*)
(dsym=0x7ffff757f4e0, sc=0x0) at src/dmd/dsymbolsem.d:105
#16 0x00005555556c39ef in dmd.mars.tryMain(ulong, const(char)**, ref
dmd.globals.Param) (argc=3, argv=0x7fffffffdd28, params=...) at
src/dmd/mars.d:439
#17 0x00005555556cffd0 in D main (_param_0=...) at src/dmd/mars.d:958
---

line at current commit:
https://github.com/dlang/dmd/blob/863fec775e2dd8b8f4788849d7b8923b70dcf279/src/dmd/initsem.d#L699

--


More information about the Digitalmars-d-bugs mailing list