Thread overview
[Issue 14536] Calling destroy() on a on an extern(C++) class causes a segfault
Aug 10, 2017
Martin Nowak
Aug 15, 2017
ZombineDev
Apr 26, 2018
Manu
Apr 27, 2018
Simen Kjaeraas
May 09, 2018
Manu
August 10, 2017
https://issues.dlang.org/show_bug.cgi?id=14536

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu

--- Comment #1 from Martin Nowak <code@dawg.eu> ---
cat > bug.d << CODE
extern(C++) class Bar {}

void main()
{
    auto inst = new Bar;
    delete inst;
}
CODE

Crashes in rt_finalize2.
Weirdly enough works with `scope` classes. I vaguely remember someone hacked
around that crash for scope classes in dmd.

--
August 15, 2017
https://issues.dlang.org/show_bug.cgi?id=14536

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--
April 26, 2018
https://issues.dlang.org/show_bug.cgi?id=14536

Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |C++, industry
                 CC|                            |turkeyman@gmail.com
                 OS|Linux                       |All
           Severity|enhancement                 |major

--- Comment #2 from Manu <turkeyman@gmail.com> ---
Modifying the priority; fixing a segfault is not an enhancement request.

destroy() is objectively broken, druntime functions shouldn't crash when given apparently valid inputs used as specified.

Also, this has been here for years now, I'd love to bring new attention to it.

--
April 27, 2018
https://issues.dlang.org/show_bug.cgi?id=14536

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #3 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
>From what I can see, it's caused here:

https://github.com/dlang/druntime/blob/master/src/rt/lifetime.d#L1393

c is null, and the first iteration of the do-while loop tries to deref it.

Probably, line 1403 (_d_monitordelete) would also fail, since C++ classes don't have the monitor. If it doesn't fail, it's unlikely to do anything nice.

--
May 09, 2018
https://issues.dlang.org/show_bug.cgi?id=14536

--- Comment #4 from Manu <turkeyman@gmail.com> ---
I dun a fix: https://github.com/dlang/druntime/pull/2176 Depends on: https://github.com/dlang/dmd/pull/8224

--
May 18, 2018
https://issues.dlang.org/show_bug.cgi?id=14536

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/0d98f69de3e4ef83eac86d8c39dce71053fda008
Fix issue 14536 - destroy() works on extern(C++) classes

https://github.com/dlang/druntime/commit/ace9f08fd743a3fc1bf6d345d05b0ee4929bfb83 Merge pull request #2176 from TurkeyMan/destroy_cpp_class

Fix issue 14536 - destroy() works on extern(C++) classes

--
May 18, 2018
https://issues.dlang.org/show_bug.cgi?id=14536

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--