Memory Corruption with AAs

Walter Bright newshound1 at digitalmars.com
Fri Apr 2 12:45:18 PDT 2010


dsimcha wrote:
> == Quote from Walter Bright (newshound1 at digitalmars.com)'s article
>> dsimcha wrote:
>>> Has anyone else still been noticing difficult to reproduce memory corruption
>>> issues in the presence of associative arrays with 2.042?  They seem to happen
>>> very infrequently and non-deterministically.  I can only reproduce them in the
>>> context of a large program.  However, they don't occur in 2.040 (the release
>>> before the array stomping patch), and they are clearly a result of memory
>>> corruption, as contents of arrays change from what I expect them to be to
>>> completely random-looking values inside a loop that does a lot of memory
>>> management and uses AAs heavily but doesn't modify the values.
>> 1. is it multithreaded?
>> 2. does your code have any dangling pointers into AAs?
> 
> The program as a whole is multithreaded, but the part where the bug occurs is an
> initialization routine that is executed before any threads other than the main one
> are launched.

It should be easier to find then, by removing all the main code and everything 
it calls.

> 
> As far as the dangling pointers question, I don't understand how there could be
> dangling pointers into GC-managed memory, since if there are pointers to it, it
> won't be freed.  (Ignoring dirty tricks that I'm not using in this case.)

What I meant was, do you save any pointers into the AAs, as in:

     auto p = &aa[key];

?



More information about the Digitalmars-d mailing list