id summary reporter owner description type status milestone component version severity resolution keywords cc 949 Memory leak in regex_match() with MSVC evansls John Maddock "{{{ I'm using regex on Windows NT4 SP6 with the MSVC++ v6 compiler. My app is statically linked with the debug multithreaded version of the MS C runtime. I've turned on memory leak checking in the app: int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); tmpFlag |= _CRTDBG_LEAK_CHECK_DF; _CrtSetDbgFlag(tmpFlag); Here's my regex_match() code sample: bool LogStream::Event(const char * subsystem, const char * name, const char * detail) { using namespace std; using namespace boost; bool rc = false; if (regex_match(string(subsystem), regex(mSubsystemFilter)) && regex_match(string(name), regex(mEventFilter))) { rc = WriteMessage(EVENT, subsystem, name, detail); } return rc; } The leak only occurs if one of the matches fails, and each failure to match generates more leakage. The first buffer leaked contains the string I'm testing against the regular expression. Here's the leaks from a single failed match. (""Proxy"" was the term that failed to match the mSubsystemFilter of ""Logger"" - the mEventFilter was "".*"".) Detected memory leaks! Dumping objects -> {363} normal block at 0x00C538C0, 33 bytes long. Data: < Proxy > 00 50 72 6F 78 79 00 CD CD CD CD CD CD CD CD CD {362} normal block at 0x00C53910, 51 bytes long. Data: <3 <9 > 33 00 00 00 06 00 00 00 3C 39 C5 00 FF FF FF FF {360} normal block at 0x00C47E80, 1024 bytes long. Data: < ~ > 02 00 00 00 98 7E C4 00 00 00 00 00 06 00 00 00 {184} normal block at 0x00C52A20, 16 bytes long. Data: < `* G 4 > 90 1C C5 00 60 2A C5 00 47 00 CC CC 34 00 00 00 {182} normal block at 0x00C52A60, 16 bytes long. Data: < * * Z 3 > 20 2A C5 00 A0 2A C5 00 5A 00 CC CC 33 00 00 00 {180} normal block at 0x00C52AA0, 16 bytes long. Data: <`* * C 2 > 60 2A C5 00 E0 2A C5 00 43 00 CC CC 32 00 00 00 {178} normal block at 0x00C52AE0, 16 bytes long. Data: < * + X 1 > A0 2A C5 00 20 2B C5 00 58 00 CC CC 31 00 00 00 {176} normal block at 0x00C52B20, 16 bytes long. Data: < * `+ Q 0 > E0 2A C5 00 60 2B C5 00 51 00 CC CC 30 00 00 00 {174} normal block at 0x00C52B60, 16 bytes long. Data: < + + E / > 20 2B C5 00 A0 2B C5 00 45 00 CC CC 2F 00 00 00 {172} normal block at 0x00C52BA0, 16 bytes long. Data: <`+ + D . > 60 2B C5 00 E0 2B C5 00 44 00 CC CC 2E 00 00 00 {170} normal block at 0x00C52BE0, 16 bytes long. Data: < + , d - > A0 2B C5 00 20 2C C5 00 64 00 CC CC 2D 00 00 00 {168} normal block at 0x00C52C20, 16 bytes long. Data: < + `, S , > E0 2B C5 00 60 2C C5 00 53 00 CC CC 2C 00 00 00 {166} normal block at 0x00C52C60, 16 bytes long. Data: < , , s + > 20 2C C5 00 A0 2C C5 00 73 00 CC CC 2B 00 00 00 {164} normal block at 0x00C52CA0, 16 bytes long. Data: <`, , U * > 60 2C C5 00 E0 2C C5 00 55 00 CC CC 2A 00 00 00 {162} normal block at 0x00C52CE0, 16 bytes long. Data: < , - u ) > A0 2C C5 00 20 2D C5 00 75 00 CC CC 29 00 00 00 {160} normal block at 0x00C52D20, 16 bytes long. Data: < , `- L ( > E0 2C C5 00 60 2D C5 00 4C 00 CC CC 28 00 00 00 {158} normal block at 0x00C52D60, 16 bytes long. Data: < - - l ' > 20 2D C5 00 A0 2D C5 00 6C 00 CC CC 27 00 00 00 {156} normal block at 0x00C52DA0, 16 bytes long. Data: <`- - e & > 60 2D C5 00 E0 2D C5 00 65 00 CC CC 26 00 00 00 {154} normal block at 0x00C52DE0, 16 bytes long. Data: < - . = % > A0 2D C5 00 20 2E C5 00 3D 00 CC CC 25 00 00 00 {152} normal block at 0x00C52E20, 16 bytes long. Data: < - `. : $ > E0 2D C5 00 60 2E C5 00 3A 00 CC CC 24 00 00 00 {150} normal block at 0x00C52E60, 16 bytes long. Data: < . . c # > 20 2E C5 00 A0 2E C5 00 63 00 CC CC 23 00 00 00 {148} normal block at 0x00C52EA0, 16 bytes long. Data: <`. . x "" > 60 2E C5 00 E0 2E C5 00 78 00 CC CC 22 00 00 00 {146} normal block at 0x00C52EE0, 16 bytes long. Data: < . / v ! > A0 2E C5 00 20 2F C5 00 76 00 CC CC 21 00 00 00 {144} normal block at 0x00C52F20, 16 bytes long. Data: < . `/ t > E0 2E C5 00 60 2F C5 00 74 00 CC CC 20 00 00 00 {142} normal block at 0x00C52F60, 16 bytes long. Data: < / / r > 20 2F C5 00 A0 2F C5 00 72 00 CC CC 1F 00 00 00 {140} normal block at 0x00C52FA0, 16 bytes long. Data: <`/ / n > 60 2F C5 00 E0 2F C5 00 6E 00 CC CC 1E 00 00 00 {138} normal block at 0x00C52FE0, 16 bytes long. Data: < / P f > A0 2F C5 00 50 10 C5 00 66 00 CC CC 1D 00 00 00 {136} normal block at 0x00C51050, 16 bytes long. Data: < / a > E0 2F C5 00 90 10 C5 00 61 00 CC CC 1C 00 00 00 {134} normal block at 0x00C51090, 16 bytes long. Data:
50 10 C5 00 D0 10 C5 00 2C 00 CC CC 1B 00 00 00 {132} normal block at 0x00C510D0, 16 bytes long. Data: < > 90 10 C5 00 10 11 C5 00 0A 00 CC CC 1A 00 00 00 {130} normal block at 0x00C51110, 16 bytes long. Data: < P z > D0 10 C5 00 50 11 C5 00 7A 00 CC CC 19 00 00 00 {129} normal block at 0x00C51150, 16 bytes long. Data: < ' > 10 11 C5 00 90 11 C5 00 27 00 CC CC 19 00 00 00 {127} normal block at 0x00C51190, 16 bytes long. Data:
50 11 C5 00 D0 11 C5 00 41 00 CC CC 18 00 00 00 {126} normal block at 0x00C511D0, 16 bytes long. Data: < ` > 90 11 C5 00 10 12 C5 00 60 00 CC CC 18 00 00 00 {124} normal block at 0x00C51210, 16 bytes long. Data: < P W > D0 11 C5 00 50 12 C5 00 57 00 CC CC 17 00 00 00 {122} normal block at 0x00C51250, 16 bytes long. Data: < w > 10 12 C5 00 90 12 C5 00 77 00 CC CC 16 00 00 00 {120} normal block at 0x00C51290, 16 bytes long. Data:
> 50 12 C5 00 D0 12 C5 00 3E 00 CC CC 15 00 00 00 {118} normal block at 0x00C512D0, 16 bytes long. Data: < < > 90 12 C5 00 10 13 C5 00 3C 00 CC CC 14 00 00 00 {116} normal block at 0x00C51310, 16 bytes long. Data: < P B > D0 12 C5 00 50 13 C5 00 42 00 CC CC 13 00 00 00 {114} normal block at 0x00C51350, 16 bytes long. Data: < b > 10 13 C5 00 90 13 C5 00 62 00 CC CC 12 00 00 00 {112} normal block at 0x00C51390, 16 bytes long. Data:
50 13 C5 00 D0 13 C5 00 39 00 CC CC 11 00 00 00 {111} normal block at 0x00C513D0, 16 bytes long. Data: < 8 > 90 13 C5 00 10 14 C5 00 38 00 CC CC 11 00 00 00 {110} normal block at 0x00C51410, 16 bytes long. Data: < P 7 > D0 13 C5 00 50 14 C5 00 37 00 CC CC 11 00 00 00 {109} normal block at 0x00C51450, 16 bytes long. Data: < 6 > 10 14 C5 00 90 14 C5 00 36 00 CC CC 11 00 00 00 {108} normal block at 0x00C51490, 16 bytes long. Data:
50 14 C5 00 D0 14 C5 00 35 00 CC CC 11 00 00 00 {107} normal block at 0x00C514D0, 16 bytes long. Data: < 4 > 90 14 C5 00 10 15 C5 00 34 00 CC CC 11 00 00 00 {106} normal block at 0x00C51510, 16 bytes long. Data: < P 3 > D0 14 C5 00 50 15 C5 00 33 00 CC CC 11 00 00 00 {105} normal block at 0x00C51550, 16 bytes long. Data: < 2 > 10 15 C5 00 90 15 C5 00 32 00 CC CC 11 00 00 00 {104} normal block at 0x00C51590, 16 bytes long. Data:
50 15 C5 00 D0 15 C5 00 31 00 CC CC 11 00 00 00 {103} normal block at 0x00C515D0, 16 bytes long. Data: < 0 > 90 15 C5 00 10 16 C5 00 30 00 CC CC 11 00 00 00 {101} normal block at 0x00C51610, 16 bytes long. Data: < P } > D0 15 C5 00 50 16 C5 00 7D 00 CC CC 10 00 00 00 {99} normal block at 0x00C51650, 16 bytes long. Data: < { > 10 16 C5 00 90 16 C5 00 7B 00 CC CC 0F 00 00 00 {97} normal block at 0x00C51690, 16 bytes long. Data:
50 16 C5 00 D0 16 C5 00 2D 00 CC CC 0E 00 00 00 {95} normal block at 0x00C516D0, 16 bytes long. Data: < # > 90 16 C5 00 10 17 C5 00 23 00 CC CC 0D 00 00 00 {93} normal block at 0x00C51710, 16 bytes long. Data: < P \ > D0 16 C5 00 50 17 C5 00 5C 00 CC CC 0C 00 00 00 {91} normal block at 0x00C51750, 16 bytes long. Data: < | > 10 17 C5 00 90 17 C5 00 7C 00 CC CC 0B 00 00 00 {89} normal block at 0x00C51790, 16 bytes long. Data:
50 17 C5 00 D0 17 C5 00 5D 00 CC CC 0A 00 00 00 {87} normal block at 0x00C517D0, 16 bytes long. Data: < [ > 90 17 C5 00 10 18 C5 00 5B 00 CC CC 09 00 00 00 {85} normal block at 0x00C51810, 16 bytes long. Data: < P ? > D0 17 C5 00 50 18 C5 00 3F 00 CC CC 08 00 00 00 {83} normal block at 0x00C51850, 16 bytes long. Data: < + > 10 18 C5 00 90 18 C5 00 2B 00 CC CC 07 00 00 00 {81} normal block at 0x00C51890, 16 bytes long. Data:
50 18 C5 00 D0 18 C5 00 2A 00 CC CC 06 00 00 00 {79} normal block at 0x00C518D0, 16 bytes long. Data: < . > 90 18 C5 00 80 19 C5 00 2E 00 CC CC 05 00 00 00 {77} normal block at 0x00C51980, 16 bytes long. Data: < ^ > D0 18 C5 00 C0 19 C5 00 5E 00 CC CC 04 00 00 00 {75} normal block at 0x00C519C0, 16 bytes long. Data: < $ > 80 19 C5 00 00 1A C5 00 24 00 CC CC 03 00 00 00 {73} normal block at 0x00C51A00, 16 bytes long. Data: < ) > C0 19 C5 00 A0 1A C5 00 29 00 CC CC 02 00 00 00 {71} normal block at 0x00C51AA0, 16 bytes long. Data: < ( > 00 1A C5 00 90 1C C5 00 28 00 CC CC 01 00 00 00 {59} normal block at 0x00C51AE0, 40 bytes long. Data: < > E0 1A C5 00 E0 1A C5 00 CD CD CD CD CD CD CD CD {58} normal block at 0x00C51B40, 12 bytes long. Data: < > CC CD CD CD E0 1A C5 00 00 00 00 00 {57} normal block at 0x00C51B80, 228 bytes long. Data: < > 0E 00 00 00 CC CD CD CD 00 00 00 00 00 00 00 00 {56} normal block at 0x00C51C90, 16 bytes long. Data: < * > A0 1A C5 00 20 2A C5 00 CD CD CD CD CD CD CD CD {55} normal block at 0x00C51CD0, 12 bytes long. Data: < ? > CC CD CD CD 90 1C C5 00 3F 00 00 00 {44} normal block at 0x00C51F80, 24 bytes long. Data: < } w > 90 7D FA 77 FF FF FF FF 00 00 00 00 00 00 00 00 }}}" Bugs closed regex None Invalid