I may have found a bug.

Maxim Fomin maxim at maxim-fomin.ru
Wed May 29 10:45:49 PDT 2013


On Wednesday, 29 May 2013 at 16:46:09 UTC, Jeremy DeHaan wrote:
> On Wednesday, 29 May 2013 at 11:08:55 UTC, Maxim Fomin wrote:
>> On Wednesday, 29 May 2013 at 10:33:32 UTC, deadalnix wrote:
>>> On Wednesday, 29 May 2013 at 07:32:42 UTC, Jeremy DeHaan 
>>> wrote:
>>>> Thoughts?
>>>
>>> static variables are thread local. Are you sure the 
>>> destructor run in the same thread as the constructor ?
>>
>> Actually it fails because _aaDelX calls gc, and gc is not 
>> reenterable. It has nothing to do with static or thread locals.
>
> But if I declare the AA as a module scope variable,static or 
> not, in a different module, then I no longer get the invalid 
> memory exception. It runs just fine.

Than AA memory deletion operation happened to be placed after 
calling finalizer. Order of finalizer calls is not specified, so 
relying in dtors on member objects which reference GC memory is 
asking for exception. Note, that I cannot reproduce your behavior 
(I still get an exception).


More information about the Digitalmars-d mailing list