[C++-sig] Re: crashes on functions with std::string arguments

Thomas Schipolowski thomas.schipolowski at tu-berlin.de
Tue Apr 5 14:56:06 CEST 2005


Thanks for the quick reply Dave!

> >  The following test code reproduces both conditions:
>
> Not by itself, it doesn't!  What Python code do you need to execute to
> generate the crash?

I simple invoke python.exe in a console window (that's also what the
debugger in the VC-IDE does) and say
>>> import test
>>> test.test1("Otto")
or
>>> test.test2("Otto")

In debug mode, the message box with the _CrtIsValidHeapPointer Assertion
Failure opens instantly before the python prompt returns. I can answer the
message box with "Retry" and get an "unidentifyable C++ exception".
When not compiled with debug, I do something like
>>> for i in range(100):
          print i, test.test2("Otto")

This prints "4" between 10 and 30 times, then prints the above mentioned
exception. If I invoke the loop statement again I usually get only one "4"
or even no "4", followed by the exception. Repeating the loop statement
further, I get varying numbers of "4"s, but never again 20... At some point,
the interpreter will crash with a memory write access violation (I dont know
the English wording of the dialog.) This can happen at any time - I have
seen it sometimes as early as the tenth invokation of test2() and sometimes
only when I terminated the interpreter via Crtl-Z after many repetitions of
the above loop command.
However, calling test2() with something that is not accepted by
extract<std::string>, e.g. test2(None) or test2(10), will never crash (I
tried the loop with range(100000)). It will print -1 as it should.


Thanks again,
Thomas.







More information about the Cplusplus-sig mailing list