Bug 22729 – ICE: Invalid array access for invalid interface definition

Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-03T02:07:35Z
Last change time
2023-07-02T13:41:39Z
Keywords
ice, pull
Assigned to
No Owner
Creator
Alexey

Comments

Comment #0 by animuspexus — 2022-02-03T02:07:35Z
I don't know what's exactly caused problem and I will give update to this ticket when I'll do something what will make this bug go away. meanwhile, here is the link to code which leads to crush (running dmd build inside examples/hello): https://github.com/AnimusPEXUS/dtk/commit/e75b7a4e1ff95f6cbc09a598cc05755bd97296d0
Comment #1 by animuspexus — 2022-02-03T19:21:56Z
trying to build same code with dub build --compiler=ldc2 leads to: --- /home/animus/dpath_work/dtk/source/dtk/platforms/sdl_desktop/utils.d(275,51): Error: template `std.string.fromStringz` cannot deduce function from argument types `!()(char[32])`, candidates are: /usr/lib/ldc/x86_64-redhat-linux-gnu/include/d/std/string.d(222,15): `fromStringz(Char)(return scope inout(Char)* cString)`
Comment #2 by animuspexus — 2022-02-04T17:05:35Z
fixed fromStringz ldc2 related error in my code. ldc2 now too crushes with some similar backtrace https://github.com/AnimusPEXUS/dtk/commit/fbd2dc1879b9259465789d9c5c8ae6ea3f46ea85
Comment #3 by animuspexus — 2022-02-04T17:09:53Z
copying here dmd and ldc2 crush messages dmd ============================================================== core.exception.AssertError@/home/animus/dlang/d_v2.098.1/dmd/src/dmd/root/array.d(310): Assertion failure ---------------- ??:? _d_assertp [0x90e0d4] ??:? inout pure nothrow @nogc @safe inout(dmd.dsymbol.Dsymbol)[] dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array.opSlice(ulong, ulong) [0x69ac96] ??:? void dmd.semantic2.Semantic2Visitor.visit(dmd.dclass.ClassDeclaration).checkInterfaceImplementations(dmd.dclass.ClassDeclaration) [0x77f6ba] ??:? _ZN16Semantic2Visitor5visitEP16ClassDeclaration [0x77f61b] ??:? _ZN16ClassDeclaration6acceptEP7Visitor [0x620fd9] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Import [0x77f0f0] ??:? _ZN6Import6acceptEP7Visitor [0x62918e] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x77eba1] ??:? _ZN6Module6acceptEP7Visitor [0x647e75] ??:? _Z9semantic2P7DsymbolP5Scope [0x77e071] ??:? int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x5d11fe] ??:? _Dmain [0x5d2fc9] dmd failed with exit code 1. ============================================================== ldc2 ============================================================== core.exception.RangeError@/builddir/build/BUILD/ldc-1.27.1-src/dmd/root/array.d(311): Range violation ---------------- ??:? onRangeError [0x7fd7ec15cd98] ??:? _d_arraybounds [0x7fd7ec15d277] ??:? void dmd.semantic2.Semantic2Visitor.visit(dmd.dclass.ClassDeclaration).checkInterfaceImplementations(dmd.dclass.ClassDeclaration) [0x5e7a3f] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP16ClassDeclaration [0x53b1b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Import [0x5398b7] ??:? _ZN16Semantic2Visitor5visitEP6Module [0x53a78b] ??:? _ZN24SemanticTimeTraceVisitorIP16Semantic2VisitorE5visitEP6Module [0x53a6a9] ??:? _Z13mars_mainBodyR5ParamR5ArrayIPKcES5_ [0x624473] ??:? _Z7cppmainv [0x82c101] ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x7fd7ec19118b] ??:? _d_run_main2 [0x7fd7ec190fa4] ??:? _d_run_main [0x7fd7ec190dfd] ??:? main [0x5240cc] ??:? [0x7fd7ebbbe55f] ??:? __libc_start_main [0x7fd7ebbbe60b] ??:? _start [0x526474] ldc2 failed with exit code 1. ==============================================================
Comment #4 by b2.temp — 2022-02-05T09:33:50Z
To help reducing you can try 1. mocking the C library in D, 2. reproduce the bug with that fake tk. Then you can dustmite the whole. Also try with older DMD versions, e.g to see if it's a regression. That can help to spot the issue.
Comment #5 by animuspexus — 2022-02-06T17:32:13Z
tried to use dustmade. maybe I use it incorrectly, but it runned for some 5-6 hours and deleted all files in directory and left only dub.json. I runned it like this: `dustmite . 'dub build' > ../dust_log 2>&1` inside of dtk dir. judging from backtraces I've provided earlier, my guess is what's going on is some circular-recursive interface check. probably, best tactic would be to add some debug printfs into those Semantic.Visitor.visit.ClassDeclaration/Class.Declaration.accept.Visitor functions and probably add some context so those functions could detect if new recursion loop iteration is trying to start. but I don't think I'm good enough to mess with dmd code.
Comment #6 by animuspexus — 2022-02-08T03:41:28Z
my project is compilable again. again, can't tell what exactly changed so bug is gone. I think this is somehow connected with ContainerableI, which I created and added just before bug appearance. thou when I simply renamed ContainerableI.d to ContainerableI.d_ and done minimal removal of ContainerableI form code dmd were still crushing. compiles: https://github.com/AnimusPEXUS/dtk/commit/6f90ca7486c7712af3fb77cf9168b501788b8cb6 next commit, first time bug appearance, added some new ContainerableI interface: https://github.com/AnimusPEXUS/dtk/commit/e75b7a4e1ff95f6cbc09a598cc05755bd97296d0 reworked code to remove ContainerableI, but this is not compilable yet: https://github.com/AnimusPEXUS/dtk/commit/379f53020fd62e43bd3130de89f9cc2f09c3d68a some more work and first successful compilation after bug: https://github.com/AnimusPEXUS/dtk/commit/57b54403e4a0381c50dd5e7e70aca55b78529d0c
Comment #7 by animuspexus — 2022-02-08T03:45:28Z
also I somewhat suspicious about `return tuple(cast(WidgetI)this, point);` lines in crush-commit
Comment #8 by animuspexus — 2022-04-01T21:25:47Z
got same bug again. I think this is about some mixture of interface recursion and mixins. still couldn't triangulate the problem, but it disappears if I comment out ': ContainerFunctionSetI' text in source/dtk/interfaces/WidgetI.d at line 24 . commited code with bug is here : https://github.com/AnimusPEXUS/dtk/commit/2a415b4b5701dd7d62b3ec916f077b0fe56935cb terminal bug report message: ----------------- --- 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.099.0 predefs SDL_204 BindSDL_Static SDL_Image BindFT_Static DTK_PLATFORM_SDL_DESKTOP Have_dtk Have_fontconfig Have_bindbc_freetype Have_bindbc_sdl Have_observable Have_bindbc_loader Have_vibe_core Have_eventcore Have_stdx_allocator EventcoreEpollDriver Have_taggedalgebraic DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 linux CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_PreConditions D_PostConditions D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat binary dmd version v2.099.0 config /home/animus/dlang/d_v2.099.0/dmd/generated/linux/release/64/dmd.conf DFLAGS -I/home/animus/dlang/d_v2.099.0/dmd/generated/linux/release/64/../../../../../druntime/import -I/home/animus/dlang/d_v2.099.0/dmd/generated/linux/release/64/../../../../../phobos -L-L/home/animus/dlang/d_v2.099.0/dmd/generated/linux/release/64/../../../../../phobos/generated/linux/release/64 -L--export-dynamic -fPIC --- core.exception.AssertError@/home/animus/dlang/d_v2.099.0/dmd/src/dmd/root/array.d(310): Assertion failure ---------------- ??:? _d_assertp [0x9280f8] /home/animus/dlang/d_v2.099.0/dmd/src/dmd/root/array.d:310 inout pure nothrow @nogc @safe inout(dmd.dsymbol.Dsymbol)[] dmd.root.array.Array!(dmd.dsymbol.Dsymbol).Array.opSlice(ulong, ulong) [0x5c9186] src/dmd/semantic2.d:626 void dmd.semantic2.Semantic2Visitor.visit(dmd.dclass.ClassDeclaration).checkInterfaceImplementations(dmd.dclass.ClassDeclaration) [0x786bae] src/dmd/semantic2.d:668 _ZN16Semantic2Visitor5visitEP16ClassDeclaration [0x786b0f] src/dmd/dclass.d:1001 _ZN16ClassDeclaration6acceptEP7Visitor [0x65b045] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:475 _ZN16Semantic2Visitor5visitEP6Import [0x7865fc] src/dmd/dimport.d:356 _ZN6Import6acceptEP7Visitor [0x6630fe] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/semantic2.d:337 _ZN16Semantic2Visitor5visitEP6Module [0x7860c0] src/dmd/dmodule.d:1476 _ZN6Module6acceptEP7Visitor [0x681bd9] src/dmd/semantic2.d:79 _Z9semantic2P7DsymbolP5Scope [0x7855d5] src/dmd/mars.d:470 int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x60a16c] src/dmd/mars.d:1002 _Dmain [0x60bf8d] dmd failed with exit code 1.
Comment #9 by animuspexus — 2022-04-01T21:28:05Z
dustmite - doesn't helps
Comment #10 by moonlightsentinel — 2022-04-02T03:25:38Z
Reduction: interface ContainerFunctionSetI { Tuple!(WidgetI) getChildAtPosition; } interface WidgetI : ContainerFunctionSetI { } class Form : ContainerI, WidgetI { } template Tuple(Specs) { enum areCompatibleTuples(Tup2)(Tuple tup1, Tup2 tup2) { tup1.field == tup2; } struct Tuple { Specs field; bool opEquals(R)(R) if (areCompatibleTuples!R) { } } }
Comment #11 by moonlightsentinel — 2022-04-02T03:27:05Z
(In reply to Alexey from comment #5) > runned it like this: `dustmite . 'dub build' > ../dust_log 2>&1` Dustmite expects a command that exits with code 0 iff the error is present in the current iteration - dub build returns code 0 for successful builds.
Comment #12 by dlang-bot — 2023-06-21T09:25:13Z
@RazvanN7 created dlang/dmd pull request #15337 "Fix Issue 22729 - ICE: Invalid array access for invalid interface definition" fixing this issue: - Fix Issue 22729 - ICE: Invalid array access for invalid interface definition https://github.com/dlang/dmd/pull/15337
Comment #13 by dlang-bot — 2023-06-21T10:36:18Z
dlang/dmd pull request #15337 "Fix Issue 22729 - ICE: Invalid array access for invalid interface definition" was merged into stable: - b026b3b07f51c678a315adac5e0f42d20e7d6ba6 by RazvanN7: Fix Issue 22729 - ICE: Invalid array access for invalid interface definition https://github.com/dlang/dmd/pull/15337
Comment #14 by dlang-bot — 2023-07-02T13:41:39Z
dlang/dmd pull request #15373 "merge stable" was merged into master: - 9b65d510217a6f011b6a91f519a33f07b0061c17 by Razvan Nitu: Fix Issue 22729 - ICE: Invalid array access for invalid interface definition (#15337) https://github.com/dlang/dmd/pull/15373