Thread overview
[Issue 22697] Segfault when accessing a recursive lambda declared inside a function generated with a mixin template
Jan 22, 2022
João Lourenço
Jan 22, 2022
João Lourenço
Jan 22, 2022
Nicholas Wilson
Jan 22, 2022
Paul Backus
Dec 17, 2022
Iain Buclaw
Dec 17, 2022
Iain Buclaw
January 22, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

João Lourenço <jlourenco5691@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlourenco5691@gmail.com

--
January 22, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

--- Comment #1 from João Lourenço <jlourenco5691@gmail.com> ---
(DMD) breaks in: DMD64 D Compiler v2.098.1
(LDC) works in: the LLVM D compiler (1.28.1)

--
January 22, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |backend, ice-on-valid-code
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m

--
January 22, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com

--- Comment #2 from Paul Backus <snarwin+bugzilla@gmail.com> ---
Created attachment 1840
  --> https://issues.dlang.org/attachment.cgi?id=1840&action=edit
Unedited stack trace (14MB uncompressed)

The segfault is the result of stack overflow due to infinite recursion.

When attempting to generate the object file, the following sequence of function calls occurs in a loop:

---
StatementPrettyPrintVisitor::visit(ExpStatement*) at src/dmd/hdrgen.d:171
ExpStatement::accept(Visitor*) at src/dmd/statement.d:477
StatementPrettyPrintVisitor::visit(CompoundStatement*) at src/dmd/hdrgen.d:195
CompoundStatement::accept(Visitor*) at src/dmd/statement.d:620
void dmd.hdrgen.statementToBuffer(dmd.statement.Statement,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:136
DsymbolPrettyPrintVisitor::bodyToBuffer(FuncDeclaration*) at
src/dmd/hdrgen.d:1629
DsymbolPrettyPrintVisitor::visit(FuncLiteralDeclaration*) at
src/dmd/hdrgen.d:1681
FuncLiteralDeclaration::accept(Visitor*) at src/dmd/func.d:3633
void dmd.hdrgen.dsymbolToBuffer(dmd.dsymbol.Dsymbol,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:797
---

The stack trace prior to entering the loop is as follows:

---
ExpressionPrettyPrintVisitor::visit(FuncExp*) at src/dmd/hdrgen.d:2196
FuncExp::accept(Visitor*) at src/dmd/expression.d:4056
void dmd.hdrgen.expressionToBuffer(dmd.expression.Expression,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:3289
void dmd.hdrgen.expToBuffer(dmd.expression.Expression, dmd.parse.PREC,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:3322
void dmd.hdrgen.objectToBuffer(dmd.root.rootobject.RootObject,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:3471
void dmd.hdrgen.tiargsToBuffer(dmd.dtemplate.TemplateInstance,
dmd.common.outbuffer.OutBuffer*, dmd.hdrgen.HdrGenState*) at
src/dmd/hdrgen.d:3444
DsymbolPrettyPrintVisitor::visit(TemplateInstance*) at src/dmd/hdrgen.d:1299
void dmd.hdrgen.toCBufferInstance(const dmd.common.outbuffer.OutBuffer*, bool)
(qualifyTypes=true, buf=0x7fffffffc7d0, ti=0x7ffff7b1fcf0) at
src/dmd/hdrgen.d:2790
TemplateInstance::toPrettyCharsHelper() at src/dmd/dtemplate.d:5974
Dsymbol::toPrettyChars(bool) at src/dmd/dsymbol.d:748
FuncDeclaration::toPrettyChars(bool) at src/dmd/func.d:1207
toSymbol::ToSymbol::visit(FuncDeclaration*) at src/dmd/tocsym.d:343
FuncDeclaration::accept(Visitor*) at src/dmd/func.d:2685
toSymbol(Dsymbol*) at src/dmd/tocsym.d:464
FuncDeclaration_toObjFile(FuncDeclaration*, bool) at src/dmd/glue.d:733
toObjFile::ToObjFile::visit(FuncDeclaration*) at src/dmd/toobj.d:311
FuncDeclaration::accept(Visitor*) at src/dmd/func.d:2685
toObjFile(Dsymbol*, bool) at src/dmd/toobj.d:1008
FuncDeclaration_toObjFile(FuncDeclaration*, bool) at src/dmd/glue.d:1263
toObjFile::ToObjFile::visit(FuncDeclaration*) at src/dmd/toobj.d:311
FuncDeclaration::accept(Visitor*) at src/dmd/func.d:2685
toObjFile(Dsymbol*, bool) at src/dmd/toobj.d:1008
genObjFile(Module*, bool) at src/dmd/glue.d:518
void dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[], const(char)*[],
const(char)[], const(char)[], bool, bool, bool, bool, bool) at
src/dmd/glue.d:120
int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) at
src/dmd/mars.d:581
D main at src/dmd/mars.d:1002
---

This stack trace was generated using gdb with a debug build of DMD master, commit 1199d3978. Some details have been omitted from the exceprts included in this comment. For the full, unedited stack trace, please see the attached file `backtrace.txt.gz`.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22697

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Severity|normal                      |critical

--