D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13111 - GC.realloc returns invalid memory for large reallocation
Summary: GC.realloc returns invalid memory for large reallocation
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2014-07-12 17:10 UTC by Rainer Schuetze
Modified: 2014-07-13 19:10 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Rainer Schuetze 2014-07-12 17:10:30 UTC
Reported by Gary Willoughby, reduced by anonymous:

import core.memory;
void main()
{
     alias T = ubyte;

     enum size1 = 2_049; /* > 2_048 = 2^^11 */
     enum size2 = 1_048_577; /* > 1_048_576 = 2^^20 */

     T* _data;
     _data = cast(T*)GC.calloc(size1, GC.BlkAttr.NO_MOVE);
     _data = cast(T*)GC.realloc(_data, size2, GC.BlkAttr.NO_MOVE);

     T* _pointer = _data;
     foreach(i; 0 .. size2)
     {
         *_pointer = 0; /* segfault at i = 1_048_576 */
         _pointer++;
     }
}
Comment 2 safety0ff.bugz 2014-07-12 17:39:39 UTC
2.065 Regression introduced by: https://github.com/D-Programming-Language/druntime/commit/4fe17c32bcfa9140e3b52e92b27474c3b60b3f95