https://issues.dlang.org/show_bug.cgi?id=13111
Issue ID: 13111
Summary: GC.realloc returns invalid memory for large
reallocation
Product: D
Version: unspecified
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
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++;
}
}
--