[Issue 23395] New: Regex leaks memory when used in multithreaded environment
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 7 16:07:24 UTC 2022
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: nobody at puremagic.com
Reporter: qigezx+dc40d6nao940k at 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();
}
}
```
--
More information about the Digitalmars-d-bugs
mailing list