Thread overview
[Issue 20471] DMD Crash
Dec 31, 2019
apham
Jun 23, 2020
Basile-z
[Issue 20471] TypeInfo_Array incorrectly initialized
Jun 23, 2020
Simen Kjaeraas
Jun 23, 2020
kinke
Jun 23, 2020
kinke
Dec 17, 2022
Iain Buclaw
December 31, 2019
https://issues.dlang.org/show_bug.cgi?id=20471

--- Comment #1 from apham <apz28@hotmail.com> ---
To make it compiles without issue -> Remove the "package.d" from compiling source


Since the modules have object defined such class "XmlAttribute(S = string) : XmlNode!S". The package.d is just an import of all modules with some alias as below. Still not able to dustmite the problem

public import pham.xml_exception;
public import pham.xml_util;
public import pham.xml_buffer;
public import pham.xml_string;
public import pham.xml_entity_table;
public import pham.xml_new;
public import pham.xml_parser;
public import pham.xml_reader;
public import pham.xml_writer;
public import pham.xml_xpath;


/** For utf8 encoded string
*/
alias XmlAttributeA = XmlAttribute!string;
alias XmlCDataA = XmlCData!string;
alias XmlCommentA = XmlComment!string;
...

/** For utf16 encoded string
*/
alias XmlAttributeW = XmlAttribute!wstring;
alias XmlCDataW = XmlCData!wstring;
alias XmlCommentW = XmlComment!wstring;
...

--
June 23, 2020
https://issues.dlang.org/show_bug.cgi?id=20471

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice

--
June 23, 2020
https://issues.dlang.org/show_bug.cgi?id=20471

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com
            Summary|DMD Crash                   |TypeInfo_Array incorrectly
                   |                            |initialized

--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
The leaf node in the stack trace is object.TypeInfo_Array.toString(), and
looking at that code
(https://github.com/dlang/druntime/blob/2cc13ead1e7e535ef8ebd1f600d4ffb508a93f98/src/object.d#L532):

override string toString() const { return value.toString() ~ "[]"; }

This will fail if value is null. Is it null though?

unittest {
    auto a = typeid("");
    import std.stdio;
    writeln(a.toString());
}

> immutable(char)[]

Doesn't look like it.

unittest {
    auto a = typeid("");
    assert(a.value !is null, "a.value is null!");
}

> [unittest] a.value is null!

Uhm...

It seems something is special cased when handling TypeInfo, so that the code in toString() doesn't run at that point. For whatever reason, this short-circuiting doesn't happen inside DMD, and so it crashes.

--
June 23, 2020
https://issues.dlang.org/show_bug.cgi?id=20471

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #3 from kinke <kinke@gmx.net> ---
(In reply to Simen Kjaeraas from comment #2)
> The leaf node in the stack trace is object.TypeInfo_Array.toString()

I think that's a wrong lead due to a faulty stacktrace. The interesting bit is

> core.exception.RangeError@dmd\root\array.d(226): Range violation

That comes from an invalid index into a dmd.root.array.Array instance (https://github.com/dlang/dmd/blob/v2.090.0/src/dmd/root/array.d#L226).

The next frame in the stacktrace seems reasonable, pointing to https://github.com/dlang/dmd/blob/v2.090.0/src/dmd/dsymbolsem.d#L3655:

FuncDeclaration fdc = cd.vtbl[vi].isFuncDeclaration();

suggesting an invalid vi index.

--
June 23, 2020
https://issues.dlang.org/show_bug.cgi?id=20471

--- Comment #4 from kinke <kinke@gmx.net> ---
Btw, this issue showing up like this is only possible because the DMD 2.090.0 Windows builds were debug builds, that's why we have enabled bounds checks, debuginfos and even line infos.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--