Bug 10338 – Bug in link.c:107

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-11T13:06:00Z
Last change time
2015-06-09T01:31:22Z
Assigned to
nobody
Creator
maxim

Comments

Comment #0 by maxim — 2013-06-11T13:06:28Z
From link.c: int findNoMainError(int fd) { static const char nmeErrorMessage[] = #if __APPLE__ "\"__Dmain\", referenced from:" #else "undefined reference to `_Dmain'" #endif ; FILE *stream = fdopen(fd, "r"); if (stream == NULL) return -1; const size_t len = 64 * 1024 - 1; char buffer[len + 1]; // + '\0' size_t beg = 0, end = len; Buffer is object of automatic lifetime, and it is not initialized, hence it effectively contains 64 garbage from stack, which may potentially corrupt data.
Comment #1 by maxim — 2013-06-11T13:52:17Z
Actually it is initialized later, but not fully and code in loop references data after position fulled by fread() which leads to garbage debug printfs.
Comment #2 by github-bugzilla — 2013-06-12T02:19:30Z