[Issue 19128] New: argument to alloca may be too large
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 30 12:19:32 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19128
Issue ID: 19128
Summary: argument to alloca may be too large
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: belka at caraus.de
In rt.arrayassign._d_arraysetassign alloca is called if the buffer should be
allocated is larger than 16 bytes:
void[16] buf = void;
void[] tmp;
if (element_size > buf.sizeof)
{
tmp = alloca(element_size)[0 .. element_size];
}
else
tmp = buf[];
It is dangerous since alloca unavailable to allocate causes undefined
behaviour, so the alloca man page states:
The alloca() function returns a pointer to the beginning of the allocated
space. If the allocation causes stack overflow, program behavior is undefined.
See related discussion:
https://github.com/D-Programming-GDC/GDC/pull/699
--
More information about the Digitalmars-d-bugs
mailing list