Bug 21398 – Name clash between import and method triggers a segfault

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-11-16T17:38:26Z
Last change time
2020-11-22T13:11:27Z
Keywords
ice
Assigned to
No Owner
Creator
Nathan Graule

Attachments

IDFilenameSummaryContent-TypeSize
1810dmd_segfault.zipsegfault reproapplication/zip1569

Comments

Comment #0 by solarliner — 2020-11-16T17:38:26Z
Created attachment 1810 segfault repro Hi, DMD has been acting up on this piece of code I have attached as reproduction. If, within main (in `app.d`), there is no reference to the custom types, then compilation and execution are fine. However as soon as I introduce one of the types I defined in `mem.d`, the compiler segfaults. I've caught a backtrace in gdb: #0 0x00005555557a1421 in _D3dmd6hdrgen13visitWithMaskFCQBc5mtype4TypehPSQBt4root9outbuffer9OutBufferPSQCxQCw11HdrGenStateZv () #1 0x00005555557a173b in _D3dmd6hdrgen13typeToBufferxFCQBc5mtype4TypePSQBs4root9outbuffer9OutBufferPSQCwQCv11HdrGenStateZv () #2 0x00005555556914f3 in Type::toChars() const () #3 0x00005555557bed49 in ExpressionSemanticVisitor::visit(CallExp*) () #4 0x00005555556f2e4c in StatementSemanticVisitor::visit(ExpStatement*) () #5 0x00005555556f383a in StatementSemanticVisitor::visit(CompoundStatement*) () #6 0x00005555556f4caf in StatementSemanticVisitor::visit(ScopeStatement*) () #7 0x00005555556f5fab in _D3dmd12statementsem15semanticNoScopeFCQBl9statement9StatementPSQCk6dscope5ScopeZQBr () #8 0x00005555557028b3 in StatementSemanticVisitor::visit(IfStatement*) () #9 0x00005555556f383a in StatementSemanticVisitor::visit(CompoundStatement*) () #10 0x000055555571e3bb in Semantic3Visitor::visit(FuncDeclaration*) () #11 0x00005555557276ba in Semantic3Visitor::visit(AggregateDeclaration*) () #12 0x000055555571c0e1 in Semantic3Visitor::visit(TemplateInstance*) () #13 0x00005555557fe0d8 in _D3dmd10dsymbolsem24templateInstanceSemanticFCQBs9dtemplate16TemplateInstancePSQCz6dscope5ScopePSQDr4root5array__T5ArrayTCQEq10expression10ExpressionZQBkZv () #14 0x00005555557b6fe4 in ExpressionSemanticVisitor::visit(ScopeExp*) () #15 0x00005555557be6c4 in ExpressionSemanticVisitor::visit(CallExp*) () #16 0x00005555557959c7 in _D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZ8visitExpMFCQCxQCa14ExpInitializerZQCx () #17 0x00005555557955bd in _D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZQBo () #18 0x000055555580c5fd in DsymbolSemanticVisitor::visit(VarDeclaration*) () #19 0x00005555557c1be1 in ExpressionSemanticVisitor::visit(DeclarationExp*) () #20 0x00005555556f2e4c in StatementSemanticVisitor::visit(ExpStatement*) () #21 0x00005555556f383a in StatementSemanticVisitor::visit(CompoundStatement*) () #22 0x000055555571e3bb in Semantic3Visitor::visit(FuncDeclaration*) () #23 0x000055555571c841 in Semantic3Visitor::visit(Module*) () #24 0x000055555576e380 in _D3dmd4mars7tryMainFmPPxaKSQz7globals5ParamZi () #25 0x000055555577889f in D main () As I am new with D, the code I wrote may not be correct, however I don't think compilers are supposed to find code so ugly they crash, lol.
Comment #1 by b2.temp — 2020-11-16T17:42:38Z
> however I don't think compilers are supposed to find code so ugly they crash yes for this kind of bug you can add the "ICE" keyword. Just did it this time.
Comment #2 by solarliner — 2020-11-16T19:12:08Z
It seems the segfault is due in `mem.d` because I import `free`, but also at the same time declare a method of the same name. I have updated the title in consequence.
Comment #3 by dlang-bot — 2020-11-17T02:42:24Z
@BorisCarvajal created dlang/dmd pull request #11972 "Issue 21398 - Name clash between import and method triggers a segfault" mentioning this issue: - Issue 21398 - Name clash between import and method triggers a segfault https://github.com/dlang/dmd/pull/11972
Comment #4 by dlang-bot — 2020-11-17T06:48:19Z
dlang/dmd pull request #11972 "Issue 21398 - Name clash between import and method triggers a segfault" was merged into stable: - e4dc0ffa5a69d01308d68a4d50b8cfdbb9ba6911 by Boris Carvajal: Fix Issue 21398 - Name clash between import and method triggers a segfault https://github.com/dlang/dmd/pull/11972
Comment #5 by dlang-bot — 2020-11-22T13:11:27Z
dlang/dmd pull request #11985 "merge stable" was merged into master: - 9664fddc015541001dd31ae649b1f246f7ce73ef by Boris Carvajal: Fix Issue 21398 - Name clash between import and method triggers a segfault https://github.com/dlang/dmd/pull/11985