digitalmars.D.bugs - [Issue 18980] New: Typesafe variadic array functions cause memory
- d-bugmail puremagic.com (32/32) Jun 13 2018 https://issues.dlang.org/show_bug.cgi?id=18980
https://issues.dlang.org/show_bug.cgi?id=18980 Issue ID: 18980 Summary: Typesafe variadic array functions cause memory corruption Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: mrjnewt gmail.com Created attachment 1703 --> https://issues.dlang.org/attachment.cgi?id=1703&action=edit Reproduction code I've attached a simple D program that builds a complex JSONValue using several helper functions with signatures like JSONValue or(JSONValue[] conditions...) {} I've found that the resulting programs have (sometimes) subtle memory corruption issues. To replicate, download the attached D file and compile & run with: dmd -run badness.d dmd -O -inline -release -run badness.d The issue manifests with optimizations on AND off, although generally differently: sometimes with bad JSON output, other times with a memory allocation failure. My guess is that the arguments to these variadic array functions are being stack allocated and passing out of scope. If you put `.dup` on the two lines indicated in the source, the problem is resolved. --
Jun 13 2018