Bug 23963 – Illegal instruction / segfault with -preview=dip1021

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2023-06-04T13:17:36Z
Last change time
2023-07-12T08:38:20Z
Keywords
ice-on-valid-code
Assigned to
No Owner
Creator
Witold Baryluk

Attachments

IDFilenameSummaryContent-TypeSize
1879richards.dMinimized with dustmiteapplication/x-dsrc232

Comments

Comment #0 by witold.baryluk+d — 2023-06-04T13:17:36Z
Created attachment 1879 Minimized with dustmite dmd v2.104.0, Linux 64-bit ulong richards() { struct task { } int qpktcount = 0; int holdcount ; task* findtcb(int id) { task* t ; import std.stdio ; writefln!"\nBad task id %d"(id); return t; } return qpktcount ; } $ dmd -c -preview=dip1021 richards.reduced/richards.d Illegal instruction (core dumped) $
Comment #1 by witold.baryluk+d — 2023-06-04T13:19:42Z
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 ()
Comment #2 by witold.baryluk+d — 2023-06-04T13:26:49Z
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 ()
Comment #3 by razvan.nitu1305 — 2023-07-12T08:38:20Z
I cannot reproduce this with latest version of the compiler.