[Issue 8875] core.exception.InvalidMemoryOperationError in case of remove() in Destructors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 26 08:51:46 PDT 2012


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


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |maxim at maxim-fomin.ru
         Resolution|                            |INVALID


--- Comment #2 from Maxim Fomin <maxim at maxim-fomin.ru> 2012-10-26 08:51:43 PDT ---
(In reply to comment #0)
> example code ( no error ):
> 
> void main(){
>     C c;
>     c = new C(0);
>     delete c;
> }
> class C{
>     static int[int] staticList;
>     int myint;
> 
>     this( int x ){
>         staticList[x] = 1;
>         myint = x;
>     }
>     ~this(){
>         staticList.remove( myint );
>     }
> }
> 
> BUT comment out "delete c;" , freeze by end of runtime.
> 
> in addition,
> code that only refer to staticList did'nt freeze.

AFAIK D garbage collector is non-reenterable. When a program returns from main
function and GC collects objects, destructors should not perform gc-related
operations because it will result in InvalidMemoryOperationError.

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


More information about the Digitalmars-d-bugs mailing list