Bug 13111 – GC.realloc returns invalid memory for large reallocation

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-12T17:10:00Z
Last change time
2014-07-13T19:10:26Z
Keywords
pull
Assigned to
nobody
Creator
r.sagitario

Comments

Comment #0 by r.sagitario — 2014-07-12T17:10:30Z
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 #1 by r.sagitario — 2014-07-12T17:19:02Z
Comment #2 by safety0ff.bugz — 2014-07-12T17:39:39Z