Thread overview
[Issue 23963] Illegal instruction / segfault with -preview=dip1021
[Issue 23963] Illegal instruction / segfalult with -preview=dip1021
Jun 04, 2023
Witold Baryluk
Jun 04, 2023
Witold Baryluk
Jun 04, 2023
Witold Baryluk
Jun 04, 2023
Witold Baryluk
Jun 04, 2023
Luís Ferreira
Jul 12, 2023
RazvanN
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

--- Comment #1 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
Minimized futher:

ulong richards() {
struct task {}
task* findtcb(int id) {
  task* t ;
  import std.stdio ;
  writefln!"%d"(id);
  return t;
}
return 1;
}



causes segfault:

Program received signal SIGILL, Illegal instruction.
0x0000555555666c60 in ParseTimeVisitor<ASTCodegen>::visit(Dsymbol*) ()
(gdb) bt
#0  0x0000555555666c60 in ParseTimeVisitor<ASTCodegen>::visit(Dsymbol*) ()
#1  0x00005555558286d1 in
dmd.dinterpret.interpretRegion(dmd.expression.Expression,
dmd.dinterpret.InterState*, dmd.dinterpret.CTFEGoal) ()
#2  0x000055555581e425 in Interpreter::visit(ArrayLiteralExp*) ()
#3  0x00005555558286d1 in
dmd.dinterpret.interpretRegion(dmd.expression.Expression,
dmd.dinterpret.InterState*, dmd.dinterpret.CTFEGoal) ()
#4  0x0000555555823929 in Interpreter::visit(StructLiteralExp*) ()
#5  0x000055555568a426 in
dmd.dinterpret.ctfeInterpret(dmd.expression.Expression) ()
#6  0x00005555556ccdee in dmd.initsem.initializerSemantic(dmd.init.Initializer,
dmd.dscope.Scope*, ref dmd.mtype.Type,
dmd.init.NeedInterpret).visitExp(dmd.init.ExpInitializer) ()
#7  0x00005555556db179 in initializerSemantic(Initializer*, Scope*, Type*&,
NeedInterpret) ()
#8  0x00005555557b7ed6 in Semantic2Visitor::visit(VarDeclaration*) ()
#9  0x00005555557b689b in Semantic2Visitor::visit(AttribDeclaration*) ()
#10 0x00005555557b689b in Semantic2Visitor::visit(AttribDeclaration*) ()
#11 0x00005555557b893a in Semantic2Visitor::visit(Module*) ()
#12 0x00005555557b67e9 in Semantic2Visitor::visit(Import*) ()
#13 0x00005555556e0c42 in Semantic3Visitor::visit(Module*) ()
#14 0x00005555558f58db in dmd.mars.tryMain(ulong, const(char)**, ref
dmd.globals.Param) ()
#15 0x00005555558ff801 in D main ()

--
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

Witold Baryluk <witold.baryluk+d@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |major

--
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

Witold Baryluk <witold.baryluk+d@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code

--
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

--- Comment #2 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
First source code (in original top comment), produces different back trace in
gdb.

Providing for completeness

Program received signal SIGILL, Illegal instruction.
0x000055555589e0bd in dmd.dmangle.mangleParameter(dmd.mtype.Parameter,
dmd.common.outbuffer.OutBuffer*, ref dmd.dmangle.Backref) ()
(gdb) bt
#0  0x000055555589e0bd in dmd.dmangle.mangleParameter(dmd.mtype.Parameter,
dmd.common.outbuffer.OutBuffer*, ref dmd.dmangle.Backref) ()
#1  0x000055555589f0b3 in dmd.dmangle.mangleFuncType(dmd.mtype.TypeFunction,
dmd.mtype.TypeFunction, ubyte, dmd.mtype.Type, dmd.common.outbuffer.OutBuffer*,
ref dmd.dmangle.Backref).__foreachbody8(ulong, dmd.mtype.Parameter) ()
#2  0x000055555566d5bc in dmd.mtype.Parameter._foreachImpl(scope int(ulong,
dmd.mtype.Parameter, ulong, dmd.mtype.Parameter) delegate, ulong,
dmd.mtype.Parameter, ref ulong, dmd.mtype.Parameter) ()
#3  0x000055555566d3fc in dmd.dmangle.mangleFuncType(dmd.mtype.TypeFunction,
dmd.mtype.TypeFunction, ubyte, dmd.mtype.Type, dmd.common.outbuffer.OutBuffer*,
ref dmd.dmangle.Backref) ()
#4  0x00005555557e8dfb in Mangler::mangleDecl(Declaration*) ()
#5  0x00005555557e80fb in toSymbol::ToSymbol::visit(FuncDeclaration*) ()
#6  0x00005555557f9c00 in dmd.e2ir.toElem(dmd.expression.Expression,
dmd.toir.IRState*).visitSymbol(dmd.expression.SymbolExp) ()
#7  0x00005555557f40b4 in toElem(Expression*, IRState*) ()
#8  0x00005555558024f9 in dmd.e2ir.toElem(dmd.expression.Expression,
dmd.toir.IRState*).visitCall(dmd.expression.CallExp) ()
#9  0x00005555557f454a in toElem(Expression*, IRState*) ()
#10 0x00005555557f3bbc in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visitExp(dmd.statement.ExpStatement)
()
#11 0x00005555557ec82a in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
    ()
#12 0x00005555557ec916 in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
    ()
#13 0x00005555557ee9ea in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
    ()
#14 0x00005555557ec82a in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
    ()
#15 0x00005555557ec82a in dmd.s2ir.Statement_toIR(dmd.statement.Statement,
dmd.toir.IRState*,
dmd.stmtstate.StmtState!(dmd.backend.cc.block).StmtState*).visit.VisitStatement(dmd.statement.Statement)
    ()
#16 0x00005555557d2091 in toObjFile::ToObjFile::visit(FuncDeclaration*) ()
#17 0x00005555557cdf81 in toObjFile::ToObjFile::visit(TemplateInstance*) ()
#18 0x00005555558d688e in genObjFile(Module*, bool) ()
#19 0x00005555558d3392 in dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[],
const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool) ()
#20 0x00005555558f5e08 in dmd.mars.tryMain(ulong, const(char)**, ref
dmd.globals.Param) ()
#21 0x00005555558ff801 in D main ()

--
June 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

Luís Ferreira <contact@lsferreira.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |contact@lsferreira.net
            Summary|Illegal instruction /       |Illegal instruction /
                   |segfalult with              |segfault with
                   |-preview=dip1021            |-preview=dip1021

--
July 12, 2023
https://issues.dlang.org/show_bug.cgi?id=23963

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
I cannot reproduce this with latest version of the compiler.

--