Bug 20855 – stack overflow when compiling large file

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-05-22T17:56:20Z
Last change time
2021-04-20T04:18:55Z
Keywords
backend, pull
Assigned to
No Owner
Creator
Kilian
See also
https://issues.dlang.org/show_bug.cgi?id=6401

Attachments

IDFilenameSummaryContent-TypeSize
1790files.tar.gzsource file and terminal outputapplication/gzip168629

Comments

Comment #0 by kilianhanich — 2020-05-22T17:56:20Z
Created attachment 1790 source file and terminal output I tried to do a D compiler benchmark between DMD and GDC (GNU's D compiler). I haven't done this so far, so I guessed that you can test the parsing speed with compiling very large files (and the Internet seemed to say that too). So, when compiling this file (which is manually unrolled loop of 100.000 times the line "a = b+c*d + a;", DMD segfaults. It happened every time I tried it, so it should be easily reproducible. My environment is Kubuntu 18.04 with DMD version 2.092.0 (like seen in the screenshot). The overwritten things in the screenshot is the Hostname (and Username). Because it unlikely that that big files are going to get parsed (and file with the same code but fewer lines were fine), I put the Severity on minor.
Comment #1 by moonlightsentinel — 2020-05-22T18:44:17Z
Seems to be a stack overflow in the optimizer: (gdb) run test100k.d Starting program: generated/linux/debug/64/dmd test100k.d Program received signal SIGSEGV, Segmentation fault. 0x000000000850d7a7 in optelem(elem*, unsigned int) (e=0xa12eec0, goal=1) at /mnt/e/repos/Dlang/forks/dmd/src/dmd/backend/cgelem.d:5226 5226 private elem * optelem(elem *e, goal_t goal)
Comment #2 by dlang-bot — 2021-04-09T08:53:53Z
@WalterBright created dlang/dmd pull request #12409 "fix Issue 20855 - stack overflow when compiling large file" fixing this issue: - fix Issue 20855 - stack overflow when compiling large file https://github.com/dlang/dmd/pull/12409
Comment #3 by dlang-bot — 2021-04-20T04:18:55Z
dlang/dmd pull request #12409 "fix Issue 20855 - stack overflow when compiling large file" was merged into master: - cbbd0e87e4f1907a5c13e922652caf4dcc90fa3e by Walter Bright: fix Issue 20855 - stack overflow when compiling large file https://github.com/dlang/dmd/pull/12409