https://issues.dlang.org/show_bug.cgi?id=23395
Issue ID: 23395 Summary: Regex leaks memory when used in multithreaded environment Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: qigezx+dc40d6nao9...@grr.la Each thread where regular expressions are used leaks memory exactly once, I think that only the first created regex leaks. This is true for (CTR) compile time and runtime regex. CTR leak much more memory. The leak grows or shrinks depending on the size of the regex. Compile the following example with "ldc2 -fsan=address -g" to see for yourself. It also works with gdc and dmd, but at least for dmd you need to use valgrind instead, which is more ambigious and less informative in it's reporting for this bug. ``` import std; void threadFun(){ auto rgx = regex(r"(?P<num>\d)"); auto res = matchFirst(words, rgx); res["num"].writeln; } void main(){ foreach(i; 0..10){ task!(threadFun).executeInNewThread(); } } ``` --