[Patch] Fix libstdc++/12352

Martin Sebor sebor@roguewave.com
Fri Sep 26 17:46:00 GMT 2003


Paolo Carlini wrote:

> Pétur Runólfsson wrote:
> 
> [snip]
> 
>> This should be detectable with the testcase I attached to the PR
>> if the outer loop is run often enough.
>>
> Thanks.
> 
> As I wrote, I didn't hope to fix *all* the problems, unfortunately...
> 
> However, I tried your testcase with a command line parameter up to 
> ~1000-3000 and nothing happened. I would appreciate if you could prepare 
> a more sensitive testcase and perhaps file a different PR, in order to 
> better keep track of the issue: in the next days I would like to work on 
> a few other PR before returning to excpetion safety.

FWIW, it's not trivial to write black box tests exercising exception
safety, especially when it comes to dynamic allocation. One approach
that has worked for me is to replace operator new with one that works
in two modes:
     -- tracking mode records all calls to it made from a program
        the program is run once in this mode to record all such calls
     -- test mode iteratively runs the program and forces operator
        new to throw an exception for each call previously recorded,
        recording any possible leaks
Obviously, this can be a pretty lengthy process.

Regards
Martin




More information about the Libstdc++ mailing list