Question about Object.destroy
Lambert Duijst via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 20 11:55:40 PDT 2015
On Sunday, 20 September 2015 at 18:50:44 UTC, Adam D. Ruppe wrote:
> On Sunday, 20 September 2015 at 18:41:18 UTC, anonymous wrote:
>> But that doesn't change either. I think Adam is mistaken here.
>
> huh, I just checked the source... and you are right, it doesn't
> set classes to null itself, but does null out the vtable inside.
>
> *ppv = null; // zero vptr even if `resetMemory` is false
>
> druntime/src/rt/lifetime.d line 1373
>
> So that's why it is segfaulting, the table of virtual functions
> is nulled after it is destroyed rather than the reference.
Oops, I think I replied too fast, did not read this reply of
yours, which answers some of my questions. If the vtable is
nulled then this will always lead to a segfault when methods of
deleted object are called, which is good because doing so is a
programming error anyway, but at least it does not lead to weird
memory corruptions etc..
More information about the Digitalmars-d-learn
mailing list