[Issue 21008] dmd segfaults because of __traits(getMember, ...) and virtual function overriding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 5 14:38:36 UTC 2020


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

moonlightsentinel at disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel at disroot.o
                   |                            |rg
           Hardware|x86                         |All

--- Comment #1 from moonlightsentinel at disroot.org ---
Reduced test case:

======================================================
class ControllerBase(T)
{
    bool after() {}

    mixin(handleMiddlewareAnnotation!T);
}

class DemoController : ControllerBase!DemoController
{
    bool after() {}
}

string handleMiddlewareAnnotation(T)()
{
    foreach (memberName; __traits(allMembers, T))
        __traits(getMember, T, memberName);
}
======================================================

Running a debug dmd yields the following trace:

dmd -c -o- test.d

---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the
reduction.
---
DMD v2.092.1

predefs   DigitalMars Posix linux ELFv1 CRuntime_Glibc CppRuntime_Gcc
LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC
assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    ../generated/linux/debug/64/dmd
version   v2.092.1

config    ../generated/linux/debug/64/dmd.conf
DFLAGS    -I../generated/linux/debug/64/../../../../../druntime/import
-I../generated/linux/debug/64/../../../../../phobos
-L-L../generated/linux/debug/64/../../../../../phobos/generated/linux/debug/64
-L--export-dynamic -fPIC
---
core.exception.RangeError at dmd/root/array.d(251): Range violation
----------------
??:? _d_arrayboundsp [0x7fc38279b939]
dmd/root/array.d:251 _ZN5ArrayIP7DsymbolEixEm [0x7fc3825e1bda]
dmd/dsymbolsem.d:3724
_ZN22DsymbolSemanticVisitor23funcDeclarationSemanticEP15FuncDeclaration
[0x7fc382551656]
dmd/dsymbolsem.d:4115 _ZN22DsymbolSemanticVisitor5visitEP15FuncDeclaration
[0x7fc382552aa4]
dmd/func.d:2564 _ZN15FuncDeclaration6acceptEP7Visitor [0x7fc3825b900d]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/typesem.d:4298 dmd.expression.Expression dmd.typesem.dotExp(dmd.mtype.Type,
dmd.dscope.Scope*, dmd.expression.Expression, dmd.identifier.Identifier,
int).visitClass(dmd.mtype.TypeClass) [0x7fc38268a516]
dmd/typesem.d:4343 dmd.expression.Expression dmd.typesem.dotExp(dmd.mtype.Type,
dmd.dscope.Scope*, dmd.expression.Expression, dmd.identifier.Identifier, int)
[0x7fc382685a02]
dmd/expressionsem.d:11889 dmd.expression.Expression
dmd.expressionsem.semanticY(dmd.expression.DotIdExp, dmd.dscope.Scope*, int)
[0x7fc3825b1cbb]
dmd/expressionsem.d:6150 _ZN25ExpressionSemanticVisitor5visitEP8DotIdExp
[0x7fc3825a02a1]
dmd/expression.d:4577 _ZN8DotIdExp6acceptEP7Visitor [0x7fc382585d59]
dmd/expressionsem.d:11487 _Z18expressionSemanticP10ExpressionP5Scope
[0x7fc3825b047b]
dmd/traits.d:1002 dmd.expression.Expression
dmd.traits.semanticTraits(dmd.expression.TraitsExp, dmd.dscope.Scope*)
[0x7fc38267876d]
dmd/expressionsem.d:5284 _ZN25ExpressionSemanticVisitor5visitEP9TraitsExp
[0x7fc38259d2a8]
dmd/expression.d:4012 _ZN9TraitsExp6acceptEP7Visitor [0x7fc38258458d]
dmd/expressionsem.d:11487 _Z18expressionSemanticP10ExpressionP5Scope
[0x7fc3825b047b]
dmd/statementsem.d:186 _ZN24StatementSemanticVisitor5visitEP12ExpStatement
[0x7fc382661179]
dmd/statement.d:750 _ZN12ExpStatement6acceptEP7Visitor [0x7fc38265cc61]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/statementsem.d:244 _ZN24StatementSemanticVisitor5visitEP17CompoundStatement
[0x7fc38266143b]
dmd/statement.d:938 _ZN17CompoundStatement6acceptEP7Visitor [0x7fc38265d4dd]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/statementsem.d:445 _ZN24StatementSemanticVisitor5visitEP14ScopeStatement
[0x7fc382661f89]
dmd/statement.d:1045 _ZN14ScopeStatement6acceptEP7Visitor [0x7fc38265d8dd]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/statementsem.d:419
_ZN24StatementSemanticVisitor5visitEP21UnrolledLoopStatement [0x7fc382661e59]
dmd/statement.d:1003 _ZN21UnrolledLoopStatement6acceptEP7Visitor
[0x7fc38265d77d]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/statementsem.d:1165 _ZN24StatementSemanticVisitor5visitEP16ForeachStatement
[0x7fc382662daf]
dmd/statement.d:1320 _ZN16ForeachStatement6acceptEP7Visitor [0x7fc38265e0d5]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/statementsem.d:244 _ZN24StatementSemanticVisitor5visitEP17CompoundStatement
[0x7fc38266143b]
dmd/statement.d:938 _ZN17CompoundStatement6acceptEP7Visitor [0x7fc38265d4dd]
dmd/statementsem.d:131 _Z17statementSemanticP9StatementP5Scope [0x7fc382661063]
dmd/semantic3.d:577 _ZN16Semantic3Visitor5visitEP15FuncDeclaration
[0x7fc382657135]
dmd/func.d:2564 _ZN15FuncDeclaration6acceptEP7Visitor [0x7fc3825b900d]
dmd/semantic3.d:81 _Z9semantic3P7DsymbolP5Scope [0x7fc382655981]
dmd/func.d:455 _ZN15FuncDeclaration17functionSemantic3Ev [0x7fc3825b3cfd]
dmd/func.d:429 _ZN15FuncDeclaration16functionSemanticEv [0x7fc3825b3c11]
dmd/expressionsem.d:918 dmd.expression.Expression
dmd.expressionsem.symbolToExp(dmd.dsymbol.Dsymbol, ref const(dmd.globals.Loc),
dmd.dscope.Scope*, bool) [0x7fc38258ea88]
dmd/expressionsem.d:3330 _ZN25ExpressionSemanticVisitor5visitEP8ScopeExp
[0x7fc382595f9b]
dmd/expression.d:3322 _ZN8ScopeExp6acceptEP7Visitor [0x7fc382582aa9]
dmd/expressionsem.d:11487 _Z18expressionSemanticP10ExpressionP5Scope
[0x7fc3825b047b]
dmd/expressionsem.d:101 bool dmd.expressionsem.expressionsToString(ref
dmd.root.outbuffer.OutBuffer, dmd.dscope.Scope*,
dmd.root.array.Array!(dmd.expression.Expression).Array*) [0x7fc38258c622]
dmd/dsymbolsem.d:2101
_ZN22DsymbolSemanticVisitor9compileItEP18CompileDeclaration [0x7fc38254c7cc]
dmd/dsymbolsem.d:2131 _ZN22DsymbolSemanticVisitor5visitEP18CompileDeclaration
[0x7fc38254ca37]
dmd/attrib.d:1298 _ZN18CompileDeclaration6acceptEP7Visitor [0x7fc3824ceded]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/dsymbolsem.d:5370 void
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).__lambda10!(dmd.dsymbol.Dsymbol).__lambda10(dmd.dsymbol.Dsymbol)
[0x7fc382557813]
dmd/dsymbol.d:99 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x7fc38253fb2b]
dmd/dsymbolsem.d:5370 _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration
[0x7fc382556a99]
dmd/dclass.d:993 _ZN16ClassDeclaration6acceptEP7Visitor [0x7fc382502009]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/dtemplate.d:7393 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*).symbolDg(dmd.dsymbol.Dsymbol)
[0x7fc38256c488]
dmd/dsymbol.d:99 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x7fc38253fb2b]
dmd/dtemplate.d:7398 void
dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*)
[0x7fc38256c414]
dmd/dtemplate.d:7413 void
dmd.dtemplate.TemplateInstance.tryExpandMembers(dmd.dscope.Scope*)
[0x7fc38256c4f2]
dmd/dsymbolsem.d:6206 void
dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance,
dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*)
[0x7fc3825592a0]
dmd/dsymbolsem.d:2829 _ZN22DsymbolSemanticVisitor5visitEP16TemplateInstance
[0x7fc38254ec2e]
dmd/dtemplate.d:7442 _ZN16TemplateInstance6acceptEP7Visitor [0x7fc38256c5ad]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/typesem.d:2831 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*,
dmd.mtype.Type*, dmd.dsymbol.Dsymbol*,
bool).visitInstance(dmd.mtype.TypeInstance) [0x7fc382684cfa]
dmd/typesem.d:3084 void dmd.typesem.resolve(dmd.mtype.Type, ref
const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.expression.Expression*,
dmd.mtype.Type*, dmd.dsymbol.Dsymbol*, bool) [0x7fc38268411e]
dmd/typesem.d:1652 dmd.mtype.Type dmd.typesem.typeSemantic(dmd.mtype.Type, ref
const(dmd.globals.Loc),
dmd.dscope.Scope*).visitInstance(dmd.mtype.TypeInstance) [0x7fc38268196c]
dmd/typesem.d:1945 _Z12typeSemanticP4TypeRK3LocP5Scope [0x7fc38267e90f]
dmd/dsymbolsem.d:5011 pure @nogc @safe dmd.mtype.Type
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).__dgliteral3()
[0x7fc3825576f1]
dmd/dsymbolsem.d:4993 dmd.mtype.Type
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dclass.ClassDeclaration).resolveBase!(dmd.mtype.Type).resolveBase(lazy
dmd.mtype.Type) [0x7fc38255a494]
dmd/dsymbolsem.d:5011 _ZN22DsymbolSemanticVisitor5visitEP16ClassDeclaration
[0x7fc3825555db]
dmd/dclass.d:993 _ZN16ClassDeclaration6acceptEP7Visitor [0x7fc382502009]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/dsymbolsem.d:2259 void
dmd.dsymbolsem.DsymbolSemanticVisitor.visit(dmd.dmodule.Module).__lambda2!(dmd.dsymbol.Dsymbol).__lambda2(dmd.dsymbol.Dsymbol)
[0x7fc38254cff0]
dmd/dsymbol.d:99 void
dmd.dsymbol.foreachDsymbol(dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array*,
void delegate(dmd.dsymbol.Dsymbol)) [0x7fc38253fb2b]
dmd/dsymbolsem.d:2256 _ZN22DsymbolSemanticVisitor5visitEP6Module
[0x7fc38254cf7f]
dmd/dmodule.d:1462 _ZN6Module6acceptEP7Visitor [0x7fc382527a99]
dmd/dsymbolsem.d:564 _Z15dsymbolSemanticP7DsymbolP5Scope [0x7fc38254774d]
dmd/mars.d:565 int dmd.mars.tryMain(ulong, const(char)**, ref
dmd.globals.Param) [0x7fc38260f3a2]
dmd/mars.d:952 _Dmain [0x7fc382610c6b]

--


More information about the Digitalmars-d-bugs mailing list