Comment #0 by demoulin.pierre — 2021-03-19T15:08:57Z
Visual Studio Community 2019 Version 16.9.2
Visual D 1.1.0
Both updated on march, 19 2021
Here's a simple code that causes VS2019 to crash while debugging.
When you just run (f5) without breakpoint; it works. you have the right outputs, the code generation and execution are right.
When you execute the main function step by step (f10), VS crash after the 2nd line.
module tst;
import std.stdio;
int main()
{
auto f1 = new Foo(null, "parent");
auto f2 = new Foo(f1, "child");
writeln (f2.parent.text);
writeln (f1.child[0].text);
readln;
return 0;
}
class Foo {
@disable this();
this ( Foo p , string txt ) {
parent = p;
text = txt;
}
string text;
private Foo _p;
private Foo[] _c;
@property auto child () {return _c;}
@property auto parent () {return _p;}
@property void parent ( Foo value ) {
if ( ! _p ) {
_p = value;
if ( _p )
_p._c[_p._c.length++] = this;
}
}
}
Comment #1 by r.sagitario — 2021-03-20T06:52:57Z
It crashes due to the child array pointing back to the original object. This causes a stack overflow because of a bad output length check.
If you want a quick fix, you can grab MagoNatCC.dll from https://ci.appveyor.com/project/rainers/mago/build/artifacts and replace the one in "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Packages\Debugger"
Comment #2 by demoulin.pierre — 2021-03-20T13:00:31Z
(In reply to Rainer Schuetze from comment #1)
> It crashes due to the child array pointing back to the original object. This
> causes a stack overflow because of a bad output length check.
>
> If you want a quick fix, you can grab MagoNatCC.dll from
> https://ci.appveyor.com/project/rainers/mago/build/artifacts and replace the
> one in "c:\Program Files (x86)\Microsoft Visual
> Studio\2019\Community\Common7\Packages\Debugger"
I did it. it's ok, i can expand both objects in the watch window; this is pure magic :)
thanks