Unknown bug disallows growth of dynamic arrays

solidstate1991 laszloszeremi at outlook.com
Thu Jul 1 20:10:08 UTC 2021


On Monday, 28 June 2021 at 20:55:44 UTC, solidstate1991 wrote:
> Here's the offending function: 
> https://github.com/ZILtoid1991/collections-d/blob/master/source/collections/sortedlist.d#L38
>
> It causes to throw an exception with `Access violation reading 
> location` and a memory address, int the function 
> `_d_arraysetlengthT`. Variable `ti` is a TypeInfo_Array, 
> `value` of this object is null.
>
> Error happens when adding a sprite in this class: 
> https://github.com/ZILtoid1991/pixelperfectengine/blob/master/pixelperfecteditor/src/app.d#L64
> However, the same doesn't happen when the editor is being run.
>
> Since leaving out any addition of sprites causes errors 
> elsewhere, I was thinking that it might be a memory leakage 
> issue. Could memory leakage cause such errors when attempting 
> to grow or shrink arrays?

It seems I could solve the issue with the reserve() function, and 
it occurred twice so far.

I often have to disable bounds checking, since it takes up 
precious CPU cycles, instead I do it in an "at once" fashion 
rather than per-index access, and need to be done in such fashion 
with the graphics rendering functions I made.


More information about the Digitalmars-d-learn mailing list