Thread overview
Got interesting bug in DMD
Oct 02, 2022
Andrey Zherikov
Oct 02, 2022
Imperatorn
Oct 03, 2022
Andrey Zherikov
Oct 03, 2022
Tejas
Oct 03, 2022
Andrey Zherikov
October 02, 2022

Unfortunately this bug is not reproducible (when I reran, DMD just segfault'ed) but it might point to the root cause of not deterministic behavior of DMD.
Note the index and array size.

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.100.2-dirty
predefs   Have_argparse DigitalMars LittleEndian D_Version2 all D_SIMD Windows Win64 CRuntime_Microsoft CppRuntime_Microsoft D_InlineAsm_X86_64 X86_64 D_LP64 D_Coverage unittest assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    C:\D\dmd2\windows\bin64\dmd.exe
version   v2.100.2-dirty
config    C:\D\dmd2\windows\bin64\sc.ini
DFLAGS    -IC:\D\dmd2\windows\bin64\..\..\src\phobos -IC:\D\dmd2\windows\bin64\..\..\src\druntime\import
---

core.exception.ArraySliceError@C:\Users\vagrant\clones\dmd\src\dmd\root\array.d(305): slice [0 .. 140698326884624] extends past source array of length 1665507498544
----------------
0x00007FF6E1C6B198
0x00007FF6E1C6B198
0x00007FF6E1C6AA82
0x00007FF6E1C5583B
0x00007FF6E1C55E6B
0x00007FF6E1C54DAA
0x00007FF6E1CA225F
0x00007FF6E18B79A8
0x00007FF6E18B7A29
0x00007FF6E18B7575
0x00007FF6E18BF59E
0x00007FF6E1A56D87
0x00007FF6E18A768A
0x00007FF6E192D8C4
0x00007FF6E18EAA39
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAA39
0x00007FF6E1A7EAE1
0x00007FF6E191970A
0x00007FF6E18FACF9
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E1A43E3C
0x00007FF6E1A4407E
0x00007FF6E19E978C
0x00007FF6E19E8F94
0x00007FF6E19333D2
0x00007FF6E18F593E
0x00007FF6E19F7C9B
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E18F49EC
0x00007FF6E19BB006
0x00007FF6E18E6F1A
0x00007FF6E1AAF6B3
0x00007FF6E1AA97FB
0x00007FF6E18D7F01
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19F94F2
0x00007FF6E1A43E3C
0x00007FF6E19F0D68
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E1A7EAE1
0x00007FF6E191970A
0x00007FF6E18FACF9
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E18F593E
0x00007FF6E192570A
0x00007FF6E18FB6D6
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E18F593E
0x00007FF6E19F7C9B
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E18F49EC
0x00007FF6E18EB317
0x00007FF6E18EA516
0x00007FF6E1AAF6B3
0x00007FF6E1AA97FB
0x00007FF6E18D7F01
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E19BB133
0x00007FF6E18E96DE
0x00007FF6E19E91EB
0x00007FF6E19F9C3A
0x00007FF6E19E8764
0x00007FF6E19F94F2
0x00007FF6E19F9C3A
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E192C039
0x00007FF6E192B8F3
0x00007FF6E1A7EB0D
0x00007FF6E191970A
0x00007FF6E18FACF9
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A2451
0x00007FF6E199F85D
0x00007FF6E192CBD5
0x00007FF6E18EAEA8
0x00007FF6E1A7EAE1
0x00007FF6E191970A
0x00007FF6E18FACF9
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E193A3CD
0x00007FF6E19A24D6
0x00007FF6E18F49EC
0x00007FF6E19E91EB
0x00007FF6E19E8764
0x00007FF6E19333D2
0x00007FF6E19310F4
0x00007FF6E1B1B127
0x00007FF6E1B2ECD8
0x00007FF6E1C5C3D9
0x00007FF6E1C5C259
0x00007FF6E1C5C01F
0x00007FF6E1C7E51C
0x00007FFAA7B7244D in BaseThreadInitThunk
0x00007FFAA85ADF78 in RtlUserThreadStart
C:\D\dmd2\windows\bin64\dmd.exe failed with exit code 1.

Process finished with exit code 2

PS I'm not able to report a bug because tracking system doesn't work with gmail.

October 02, 2022

On Sunday, 2 October 2022 at 11:18:49 UTC, Andrey Zherikov wrote:

>

[...]

Same with nightly?

October 03, 2022

On Sunday, 2 October 2022 at 11:35:17 UTC, Imperatorn wrote:

>

On Sunday, 2 October 2022 at 11:18:49 UTC, Andrey Zherikov wrote:

>

[...]

Same with nightly?

As I said, I can't reproduce exactly this message - dmd fails with segfault usually. Even nightly (DMD64 D Compiler v2.100.2-beta.1) fails:

Program received signal SIGSEGV, Segmentation fault.
0x00005555556d2830 in ScopeDsymbol::search(Loc const&, Identifier*, int) ()

(gdb) where
#0  0x00005555556d2830 in ScopeDsymbol::search(Loc const&, Identifier*, int) ()
#1  0x00005555556d2926 in ScopeDsymbol::search(Loc const&, Identifier*, int) ()
#2  0x00005555556db321 in dmd.typesem.dotExp(dmd.mtype.Type, dmd.dscope.Scope*, dmd.expression.Expression, dmd.identifier.Identifier, int) ()
#3  0x00005555556e8235 in dmd.expressionsem.semanticY(dmd.expression.DotIdExp, dmd.dscope.Scope*, int) ()
#4  0x00005555558497d1 in ExpressionSemanticVisitor::visit(CallExp*) ()
#5  0x000055555589ec2a in dmd.initsem.inferType(dmd.init.Initializer, dmd.dscope.Scope*) ()
#6  0x000055555567dd10 in DsymbolSemanticVisitor::visit(VarDeclaration*) ()
#7  0x000055555583ab20 in ExpressionSemanticVisitor::visit(DeclarationExp*) ()
#8  0x0000555555738fba in StatementSemanticVisitor::visit(ExpStatement*) ()
#9  0x000055555573954c in StatementSemanticVisitor::visit(CompoundStatement*) ()
#10 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#11 0x00005555556be2fc in Semantic3Visitor::visit(TemplateInstance*) ()
#12 0x00005555556f666a in dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#13 0x00005555556f4c51 in dmd.dtemplate.functionResolve(ref dmd.declaration.MatchAccumulator, dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, const(char)**) ()
#14 0x00005555556b921c in dmd.func.resolveFuncCall(ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, dmd.func.FuncResolveFlag) ()
#15 0x0000555555848b84 in ExpressionSemanticVisitor::visit(CallExp*) ()
#16 0x00005555557252e5 in StatementSemanticVisitor::visit(ReturnStatement*) ()
#17 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#18 0x00005555556be2fc in Semantic3Visitor::visit(TemplateInstance*) ()
#19 0x00005555556f66d3 in dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#20 0x00005555556f4c51 in dmd.dtemplate.functionResolve(ref dmd.declaration.MatchAccumulator, dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, const(char)**) ()
#21 0x00005555556b921c in dmd.func.resolveFuncCall(ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, dmd.func.FuncResolveFlag) ()
#22 0x0000555555848b84 in ExpressionSemanticVisitor::visit(CallExp*) ()
#23 0x00005555557252e5 in StatementSemanticVisitor::visit(ReturnStatement*) ()
#24 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#25 0x00005555558413d4 in ExpressionSemanticVisitor::visit(FuncExp*) ()
#26 0x00005555556b0233 in dmd.typesem.resolve(dmd.mtype.Type, ref const(dmd.globals.Loc), dmd.dscope.Scope*, out dmd.expression.Expression, out dmd.mtype.Type, out dmd.dsymbol.Dsymbol, bool) ()
#27 0x00005555556754ca in typeSemantic(Type*, Loc const&, Scope*) ()
#28 0x000055555583c04a in ExpressionSemanticVisitor::visit(IsExp*) ()
#29 0x000055555589ec2a in dmd.initsem.inferType(dmd.init.Initializer, dmd.dscope.Scope*) ()
#30 0x000055555567dd10 in DsymbolSemanticVisitor::visit(VarDeclaration*) ()
#31 0x00005555556faa6a in dmd.dtemplate.TemplateInstance.expandMembers(dmd.dscope.Scope*) ()
#32 0x00005555556f6460 in dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#33 0x0000555555841d38 in ExpressionSemanticVisitor::visit(ScopeExp*) ()
#34 0x00005555556d9865 in dmd.staticcond.evalStaticCondition(dmd.dscope.Scope*, dmd.expression.Expression, dmd.expression.Expression, out bool, dmd.root.array.Array!(dmd.expression.Expression).Array*).impl(dmd.expression.Expression) ()
#35 0x0000555555799bba in StaticIfCondition::include(Scope*) ()
#36 0x000055555573adc4 in dmd.statementsem.flatten(dmd.statement.Statement, dmd.dscope.Scope*) ()
#37 0x000055555573b49a in dmd.statementsem.flatten(dmd.statement.Statement, dmd.dscope.Scope*) ()
#38 0x000055555573b49a in dmd.statementsem.flatten(dmd.statement.Statement, dmd.dscope.Scope*) ()
#39 0x000055555573946e in StatementSemanticVisitor::visit(CompoundStatement*) ()
#40 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#41 0x00005555558413d4 in ExpressionSemanticVisitor::visit(FuncExp*) ()
#42 0x0000555555847862 in ExpressionSemanticVisitor::visit(CallExp*) ()
#43 0x000055555589ec2a in dmd.initsem.inferType(dmd.init.Initializer, dmd.dscope.Scope*) ()
#44 0x000055555567dd10 in DsymbolSemanticVisitor::visit(VarDeclaration*) ()
#45 0x000055555583ab20 in ExpressionSemanticVisitor::visit(DeclarationExp*) ()
#46 0x0000555555738fba in StatementSemanticVisitor::visit(ExpStatement*) ()
#47 0x000055555573954c in StatementSemanticVisitor::visit(CompoundStatement*) ()
#48 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#49 0x00005555556be2fc in Semantic3Visitor::visit(TemplateInstance*) ()
#50 0x00005555556f666a in dmd.dsymbolsem.templateInstanceSemantic(dmd.dtemplate.TemplateInstance, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.expression.Expression).Array*) ()
#51 0x00005555556f4c51 in dmd.dtemplate.functionResolve(ref dmd.declaration.MatchAccumulator, dmd.dsymbol.Dsymbol, dmd.globals.Loc, dmd.dscope.Scope*, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, const(char)**) ()
#52 0x00005555556b921c in dmd.func.resolveFuncCall(ref const(dmd.globals.Loc), dmd.dscope.Scope*, dmd.dsymbol.Dsymbol, dmd.root.array.Array!(dmd.root.rootobject.RootObject).Array*, dmd.mtype.Type, dmd.root.array.Array!(dmd.expression.Expression).Array*, dmd.func.FuncResolveFlag) ()
#53 0x0000555555848b84 in ExpressionSemanticVisitor::visit(CallExp*) ()
#54 0x00005555557252e5 in StatementSemanticVisitor::visit(ReturnStatement*) ()
#55 0x000055555573954c in StatementSemanticVisitor::visit(CompoundStatement*) ()
#56 0x00005555556bfddb in Semantic3Visitor::visit(FuncDeclaration*) ()
#57 0x00005555556be2fc in Semantic3Visitor::visit(TemplateInstance*) ()
October 03, 2022

On 10/2/22 7:18 AM, Andrey Zherikov wrote:

>

Unfortunately this bug is not reproducible (when I reran, DMD just segfault'ed) but it might point to the root cause of not deterministic behavior of DMD.

Is this an open source project or a project you are willing to share the code for so it can be tested outside your environment?

This looks like memory corruption.

-Steve

October 03, 2022

On Monday, 3 October 2022 at 14:48:57 UTC, Steven Schveighoffer wrote:

>

On 10/2/22 7:18 AM, Andrey Zherikov wrote:

>

Unfortunately this bug is not reproducible (when I reran, DMD just segfault'ed) but it might point to the root cause of not deterministic behavior of DMD.

Is this an open source project or a project you are willing to share the code for so it can be tested outside your environment?

This looks like memory corruption.

-Steve

I think it's his argparse package code, judging by a couple of lines of the entire output he posted

October 03, 2022

On Monday, 3 October 2022 at 15:18:09 UTC, Tejas wrote:

>

On Monday, 3 October 2022 at 14:48:57 UTC, Steven Schveighoffer wrote:

>

On 10/2/22 7:18 AM, Andrey Zherikov wrote:

>

Unfortunately this bug is not reproducible (when I reran, DMD just segfault'ed) but it might point to the root cause of not deterministic behavior of DMD.

Is this an open source project or a project you are willing to share the code for so it can be tested outside your environment?

This looks like memory corruption.

-Steve

I think it's his argparse package code, judging by a couple of lines of the entire output he posted

Yes, it's argparse but refactored a bit. I pushed my work-in-progress branch so: