std::string crash with optimisations
std::string crash with optimisations
- Subject: std::string crash with optimisations
- From: Dario Accornero <email@hidden>
- Date: Fri, 14 Nov 2003 16:52:01 +0100
Hello,
My Carbon application links against a few system frameworks plus three
in-house static libraries. Building it on Jaguar with gcc 3.1 under PB
2.1 results in working debug and release versions. Building it on
Panther with gcc 3.3 under Xcode results in working debug/non-working
release versions -- the latters crash thusly:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x00cdd000
Thread 0 Crashed:
#0 0xffff8a50 in __memcpy (__memcpy + 688)
#1 0x0002e65c in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::_Rep::_M_clone(std::allocator<char> const&,
unsigned long) (LWScenePlugIn.cpp:261)
#2 0x0002c5f0 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::reserve(unsigned long) (LWScenePlugIn.cpp:261)
#3 0x0002ca2c in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::append(unsigned long, char)
(LWScenePlugIn.cpp:261)
#4 0x00009b54 in Wml::MemFile::ReadEvenString(int*)
(basic_string.h:483)
The guilty code is the following:
string MemFile::ReadEvenString (int* piBytes)
{
string aStr;
if ( m_bFileLoaded && DataAvailable() )
{
*piBytes = 0;
bool bLoop = true;
while ( bLoop )
{
char cCurrentChar = *m_pcCurrent++;
++(*piBytes);
if ( cCurrentChar && DataAvailable() )
aStr += cCurrentChar;
else
{
if ( (*piBytes) & 1 )
{
++m_pcCurrent;
++(*piBytes);
}
bLoop = false;
}
}
m_lMarker += *piBytes;
}
return aStr;
}
The crash occurs on line
aStr += cCurrentChar;
This looks legal to me, and it works fine when compiling with -O0. It
works fine on Jaguar with gcc 3.1 even when compiling with -Os.
The offending source file, in release builds, has the following options:
-arch ppc -pipe -Wno-trigraphs -fno-rtti -fpascal-strings -g -O1
-Wno-four-char-constants -Wall -fmessage-length=0 -mtune=G4
Am I missing something or is there a known issue with std::string in
non-O0 builds?
Thanks,
Dario
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.