[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2015-02-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #31 from github-bugzi...@puremagic.com ---
Commit pushed to 2.067 at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/dbbea7c5bd4d8936dc8cb523b65f771842f2a487
Merge pull request #864 from Orvid/structDestructors

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2015-01-15 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #30 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/dbbea7c5bd4d8936dc8cb523b65f771842f2a487
Merge pull request #864 from Orvid/structDestructors

Fix Issue 2834 - The GC will now call destructors on heap allocated structs

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2015-01-15 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #28 from Orvid King blah38...@gmail.com ---
Where should I add it? It can't be in rt.lifetime, because that's not exposed 
to the user.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #29 from Andrei Alexandrescu and...@erdani.com ---
core.memory?

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #27 from Andrei Alexandrescu and...@erdani.com ---
Could you please add a function to druntime callStructDtorsDuringGC(bool)? That
would give a chance people who have issues with the called destructors to
revert back to the old behavior until they fix their code.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #25 from Orvid King blah38...@gmail.com ---
Fine by me.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

hst...@quickfur.ath.cx changed:

   What|Removed |Added

 CC||hst...@quickfur.ath.cx

--- Comment #26 from hst...@quickfur.ath.cx ---
Let's do it. This issue has been waiting since 2009. It's about time we did
this right.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #23 from Orvid King blah38...@gmail.com ---
And another update.

The fix to the other issue that this encountered has already been merged, and
the main DRuntime PR has been running green on the autotester for a while now.
It's just awaiting a final review and merge. I've also been doing my local
projects with the man DRuntime PR included, and have yet to encounter any
issues on win32, so I believe that it is stable.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #24 from Andrei Alexandrescu and...@erdani.com ---
Ready to take the big step with 2.067?

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #22 from Orvid King blah38...@gmail.com ---
Ok, so, to give an update on this issue, I've now implemented the invoking of
destructors on heap allocated structs, as well as arrays of structs. It
required a fix to a bug in DMD with the delete operator, as well as a change
(which I still need to make), to the test suite so that it doesn't allocate in
a destructor.

The DMD PR is here:
https://github.com/D-Programming-Language/dmd/pull/3727
And the druntime PR, as mentioned farther up, is here:
https://github.com/D-Programming-Language/druntime/pull/864

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

Dmitry Olshansky dmitry.o...@gmail.com changed:

   What|Removed |Added

 CC||dmitry.o...@gmail.com

--- Comment #20 from Dmitry Olshansky dmitry.o...@gmail.com ---
(In reply to Orvid King from comment #19)
 We still wouldn't be able to call the destructors in structs for arrays even 
 with precise heap scanning, because we can't know that each value in the
 array 
 is actually valid. Take for instance an array of File's, it's not valid to
 call 
 the destructor of File.init, so we could compare the value of an element of
 an 
 array of structs to it's init value, but who's to say that element was ever 
 initialized in the first place? How would we detect that?

It's perfectly valid to call destructor on T.init. In fact compiler will always
do so with stack-allocated instances.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

Rainer Schuetze r.sagita...@gmx.de changed:

   What|Removed |Added

 CC||r.sagita...@gmx.de

--- Comment #21 from Rainer Schuetze r.sagita...@gmx.de ---
(In reply to Orvid King from comment #19)
 We still wouldn't be able to call the destructors in structs for arrays even 
 with precise heap scanning
[...]
 How would we detect that?

The array handling in lifetime.d should supply a type info with a destructor
that iterates over the elements and calls their destructor. You might have to
generate that typeinfo at runtime, though.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #15 from Orvid King blah38...@gmail.com ---
Would making all the writeln's in http://dpaste.dzfl.pl/fbb4a15cda14 print out
be an acceptable solution to this issue? (that is, making heap-allocated
structs call their destructors)

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

David Nadlinger c...@klickverbot.at changed:

   What|Removed |Added

 CC||c...@klickverbot.at

--- Comment #16 from David Nadlinger c...@klickverbot.at ---
(In reply to Orvid King from comment #15)
 Would making all the writeln's in http://dpaste.dzfl.pl/fbb4a15cda14 print
 out be an acceptable solution to this issue? (that is, making heap-allocated
 structs call their destructors)

As far as I can see, this would not necessarily test structs contained in other
structs/classes/arrays.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

Orvid King blah38...@gmail.com changed:

   What|Removed |Added

 CC||blah38...@gmail.com

--- Comment #17 from Orvid King blah38...@gmail.com ---
https://github.com/D-Programming-Language/druntime/pull/864

It's not feasibly possible to call destructors on heap-allocated arrays of
structures, however this PR does implement the calling of destructors for
structs allocated directly on the heap.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #18 from Jonathan M Davis jmdavisp...@gmx.com ---
(In reply to Orvid King from comment #17)
 https://github.com/D-Programming-Language/druntime/pull/864
 
 It's not feasibly possible to call destructors on heap-allocated arrays of
 structures, however this PR does implement the calling of destructors for
 structs allocated directly on the heap.

As I understand it, it should be possible to call the destructors for structs
in arrays if we have the additional type information required for precise heap
scanning, but until we add that, we're stuck. But if you can make it so that
the destructors get called in other circumstances, that's a great improvement
regardless.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-04 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #19 from Orvid King blah38...@gmail.com ---
We still wouldn't be able to call the destructors in structs for arrays even 
with precise heap scanning, because we can't know that each value in the array 
is actually valid. Take for instance an array of File's, it's not valid to call 
the destructor of File.init, so we could compare the value of an element of an 
array of structs to it's init value, but who's to say that element was ever 
initialized in the first place? How would we detect that?

I think the best thing to do with the arrays of structs that have destructors 
is to simply make them illegal, and to present as an alternative, an array of a 
structure that you have defined and has an inner alias this to the original 
structure, but rather than having a destructor, has a named method that the 
user would have to call themselves for each element that they know is 
initialized.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

Benoit Rostykus benoit.rosty...@adroll.com changed:

   What|Removed |Added

 CC||benoit.rosty...@adroll.com

--- Comment #12 from Benoit Rostykus benoit.rosty...@adroll.com ---
AdRoll (the company I work for) just put a $1000 bounty on this bug:
https://www.bountysource.com/issues/2900969-struct-destructors-are-not-called-by-the-gc-but-called-on-explicit-delete

We are really excited about D, and would generally love to see any work on
improving D's GC!

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

Jonathan M Davis jmdavisp...@gmx.com changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com

--- Comment #13 from Jonathan M Davis jmdavisp...@gmx.com ---
I'd strongly argue that we make it so that struct destructors get called when
the memory for a struct is freed on the GC heap (though that pretty requires
what precise heap scanning requires as Sean points out). However, it should be
pointed out that there's no guarantee (and likely never will be a guarantee)
that everything on the heap will be collected, which would mean that it will
never be guaranteed that all struct destructors will be called when on the heap
- just that they would be called in the cases where the struct is collected and
freed by the GC.

So, while we should be able to make it so that struct destructors on the GC
heap get called much more (as opposed to never), it will almost certainly be
the case that the non-GC heap (along with some kind of manual memory management
or reference-counting) will have to be used if it's _required_ that the
destructor be run (though technically, not even that would guarantee it, since
the program could still segfault, or an Error could be thrown, or the computer
could lose power or some other incident could occur which would make it so that
the program terminated prematurely, in which case, the destructors wouldn't be
run).

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-07-03 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2834

--- Comment #14 from Jonathan M Davis jmdavisp...@gmx.com ---
(In reply to Benoit Rostykus from comment #12)
 AdRoll (the company I work for) just put a $1000 bounty on this bug:

That's quite the bounty.

--


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-02-28 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=2834


Dicebot pub...@dicebot.lv changed:

   What|Removed |Added

 CC||pub...@dicebot.lv
   Platform|x86 |All
 OS/Version|Windows |All


--- Comment #10 from Dicebot pub...@dicebot.lv 2014-02-28 04:53:17 PST ---
Updated flags as it affects all platforms and is general language defect.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2014-02-28 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=2834


rswhi...@googlemail.com changed:

   What|Removed |Added

 CC||rswhi...@googlemail.com


--- Comment #11 from rswhi...@googlemail.com 2014-02-28 05:35:48 PST ---
Maybe we should put a bounty on it.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


Re: [Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-11-22 Thread Max Samukha

On 11/21/2010 08:20 PM, Sean Kelly wrote:

d-bugm...@puremagic.com  wrote:

http://d.puremagic.com/issues/show_bug.cgi?id=2834


Max Samukhasamu...@voliacable.com  changed:

What|Removed |Added

  CC|
|samu...@voliacable.com


--- Comment #8 from Max Samukhasamu...@voliacable.com  2010-11-18
03:39:17 PST ---
So what is the verdict? Should we simply specify that struct
destructors are
not automatically called except in RAII and remove the struct-in-class
special
case?

BTW, there are other problems (serious IMO):

auto ss = new S[10];
ss.length = 5;
delete ss;

Destructors are not called on the last 5 elements.


auto ss = new S[10];
ss ~= ss;
delete ss;

We have a nasty problem when destructors are called on the appended
elements
because postblits was not run for them during append.

etc

Essentially, operations on arrays of structs with postblits/dtors
defined are
currently unusable.


I think this is unavoidable. Consider:

auto a = new T[5];
auto b = a[4..5];
a.length = 4;

We can't safely destroy a[4] because it's aliased. Also, since there's
no concept of an owner reference vs an alias, modifying the length of b
could screw up a as well.

For this and other reasons I'm inclined to withdraw this issue, and
declare that since structs are value types they won't be automatically
destroyed when collected by the GC or when held in arrays.


I agree that correct automatic struct destruction is impossible without 
significant changes to arrays/slices/GC.





Re: [Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-11-21 Thread Sean Kelly
d-bugm...@puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=2834
 
 
 Max Samukha samu...@voliacable.com changed:
 
What|Removed |Added
 
  CC|   
 |samu...@voliacable.com
 
 
 --- Comment #8 from Max Samukha samu...@voliacable.com 2010-11-18
 03:39:17 PST ---
 So what is the verdict? Should we simply specify that struct
 destructors are
 not automatically called except in RAII and remove the struct-in-class
 special
 case?
 
 BTW, there are other problems (serious IMO):
 
 auto ss = new S[10];
 ss.length = 5;
 delete ss; 
 
 Destructors are not called on the last 5 elements.
 
 
 auto ss = new S[10];
 ss ~= ss;
 delete ss;
 
 We have a nasty problem when destructors are called on the appended
 elements
 because postblits was not run for them during append.
 
 etc
 
 Essentially, operations on arrays of structs with postblits/dtors
 defined are
 currently unusable.

I think this is unavoidable. Consider:

auto a = new T[5];
auto b = a[4..5];
a.length = 4;

We can't safely destroy a[4] because it's aliased. Also, since there's
no concept of an owner reference vs an alias, modifying the length of b
could screw up a as well. 

For this and other reasons I'm inclined to withdraw this issue, and
declare that since structs are value types they won't be automatically
destroyed when collected by the GC or when held in arrays.


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-11-18 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834


Max Samukha samu...@voliacable.com changed:

   What|Removed |Added

 CC||samu...@voliacable.com


--- Comment #8 from Max Samukha samu...@voliacable.com 2010-11-18 03:39:17 
PST ---
So what is the verdict? Should we simply specify that struct destructors are
not automatically called except in RAII and remove the struct-in-class special
case?

BTW, there are other problems (serious IMO):

auto ss = new S[10];
ss.length = 5;
delete ss; 

Destructors are not called on the last 5 elements.


auto ss = new S[10];
ss ~= ss;
delete ss;

We have a nasty problem when destructors are called on the appended elements
because postblits was not run for them during append.

etc

Essentially, operations on arrays of structs with postblits/dtors defined are
currently unusable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-11-18 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834



--- Comment #9 from Max Samukha samu...@voliacable.com 2010-11-18 03:59:12 
PST ---
(In reply to comment #8)
 We have a nasty problem when destructors are called on the appended elements
 because postblits was not run for them during append.

I meant the problem is the destructors called on objects that have not been
postblitted.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-07-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #6 from bearophile_h...@eml.cc 2010-07-11 15:16:07 PDT ---
For the moment the compiler can show a warning when the code allocates on the
heap a struct that has a destructor.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-07-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834



--- Comment #7 from bearophile_h...@eml.cc 2010-07-11 17:24:58 PDT ---
One case where struct destructors are not called, in this situation it seems
simpler for the GC to know what destructors to call:


import core.memory: GC;
import core.stdc.stdio: printf;
struct Foo {
int x;
this(int xx) { this.x = xx; }
~this() { printf(Foo dtor x: %d\n, x); }
}
void main() {
Foo[] a;
a.length = 2;
a[0].x = 1;
a[1].x = 2;
// delete a;
}


(I am not sure, but a type information can be useful in arrays, maybe to fix
bug 2095 too.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-07-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834


Rob Jacques sandf...@jhu.edu changed:

   What|Removed |Added

 CC||and...@metalanguage.com


--- Comment #1 from Rob Jacques sandf...@jhu.edu 2010-07-09 23:20:01 PDT ---
*** Issue 4442 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-07-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834


Sean Kelly s...@invisibleduck.org changed:

   What|Removed |Added

 CC||s...@invisibleduck.org


--- Comment #4 from Sean Kelly s...@invisibleduck.org 2010-07-10 08:40:16 PDT 
---
What about structs whose memory are freed by the GC?  Would you expect their
dtors to be called?  They aren't.  Try allocating ten million structs in a
loop, not one dtor line will print.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-07-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2834



--- Comment #5 from Sean Kelly s...@invisibleduck.org 2010-07-10 08:41:54 PDT 
---
Fixing this will probably be fairly involved.  The GC will have to store a
TypeInfo reference for each block that needs to be finalized.  The best
approach may be to integrate this with precise scanning, since that requires
detailed type info too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---