[Issue 18692] assignment of std.regex.Captures reads freed memory from 2.072.0 to 2.078.3 inclusive

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 29 08:08:15 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18692

Dmitry Olshansky <dmitry.olsh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh at gmail.com

--- Comment #1 from Dmitry Olshansky <dmitry.olsh at gmail.com> ---
> ... the "Use ref-counting for Captures struct" from @DmitryOlshansky, could be right.  How can he get away with having the _refcount that applies to big_matches not stored in an object with the same lifetime as big_matches?  I have about two days' familiarity with D, so I assume I'm missing something.  That said, here's a program that goes wrong with the first release of dmd that included that change.  First, it working on the preceding version.

Indeed looking at it now, it doesn't seem right. Awfully so.

It likely passed though because captures is typically a temporary.

Instead it should allocate and equivalent of 

struct Payload {
 uint refcount;
 Group[0] matches;
}

Thanks for reporting!

--


More information about the Digitalmars-d-bugs mailing list