[C++-sig] [c++-sig] python std::string assignment

Matthew Scouten (TT) Matthew.Scouten at tradingtechnologies.com
Fri Oct 17 17:34:20 CEST 2008


I saw a problem vary similar to this when I was accidently mixing debug
and non-debug libraries in the same pyd. It seems that the debug version
of MS's std::string has an some kind of extra debug flag in it. If you
mix them you get corruption and other weird behavior. 

-----Original Message-----
From:
cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at python.org
[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at py
thon.org] On Behalf Of David Abrahams
Sent: Friday, October 17, 2008 9:32 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] [c++-sig] python std::string assignment


on Fri Oct 17 2008, Stefan Seefeld <seefeld-AT-sympatico.ca> wrote:

> Furkan Kuru wrote:
>> By the way
>>
>> I tried
>> "resize"ing and "reserve"ing of strings
>> by
>>
>> name.resize(1024);
>> or
>> name.reserve(1024);
>>
>> but it did not fix the problem.
>>
>> It seems that it allows up to 15 chars + null character total
16chars.
>> I think strings set longer than 15 chars corrupts the stack.
>
> I remember having seen similar behavior in a former life of mine, when
> I had to work with various MS platforms. I'm pretty sure this is
> entirely unrelated to your use of boost, but rather caused by your
> compilation settings such as mixing different Windows runtime
> libraries for the different components of your application.

Yes, that seems very likely; this looks a bit like the small string
optimization gone awry.  Perhaps you have mixed the MS runtime lib
headers with a different version of the binary library.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


More information about the Cplusplus-sig mailing list