data corruption

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 6 12:35:41 PDT 2010


On Tue, 06 Apr 2010 08:12:55 -0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Mon, 05 Apr 2010 20:06:30 -0400, Ellery Newcomer  
> <ellery-newcomer at utulsa.edu> wrote:
>
>> Hey folks,
>>
>> I've got this screwy problem with my old version of dmdz.
>>
>> One of the functions runs through a loop that appends to a string[]  
>> about four or five times. When it's chewing through a large amount of  
>> source code, maybe 1 call out of 200 the third element of the array  
>> gets corrupted just after an append.
>>
>> duping the string that gets appended has no effect.
>>
>> Trying to print out the pointer addresses to the strings does seem to  
>> get rid of the problem.
>>
>> I'm using dmd 2.042; it doesn't seem to happen on 2.040
>
> Others have seen similar issues, can you email me directly, and perhaps  
> we can get to the bottom of it?
>
> We had memory corruption issues I introduced with my array append patch  
> in 2.041, and I thought I squashed them all, but I should be able to  
> find the bug reasonably quickly if I have a reproducible test case.

Thanks to Ellery's help, I found another bug in the new array append code  
that can corrupt memory in certain cases.

If any of you need this fix right away and are comfortable rebuilding  
druntime and phobos, the patch can be found here:

http://www.dsource.org/projects/druntime/changeset/282?format=diff&new=282

You may have to tweak things a bit to get the patch to work, or you can  
just make the changes yourself (they are quite small).  For instance, I  
had to change the file to unix file format to get the patch applied on  
linux.

I expect a new dmd will be released in the near future to fix this issue.   
My apologies to those who have wasted time trying to debug this...

-Steve



More information about the Digitalmars-d mailing list