Bug 19128 – argument to alloca may be too large

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-07-30T12:19:32Z
Last change time
2018-12-18T12:43:33Z
Assigned to
No Owner
Creator
Eugene Wissner

Comments

Comment #0 by belka — 2018-07-30T12:19:32Z
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
Comment #1 by github-bugzilla — 2018-12-18T12:43:32Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/f6ef2b8634f2b0b791a9dd0f2963619344fbad20 Fix issue 19128 - argument to alloca may be too large https://github.com/dlang/druntime/commit/ab890e0fb09cb6142806bf3d2cfd0a363936a298 Merge pull request #2409 from ibuclaw/pr2258 Fix issue 19128 - argument to alloca may be too large