Topic
  • No replies
Dritter29
Dritter29
1 Post

Pinned topic Test randomly crashes when run under Purify

‏2012-08-06T15:51:15Z |
I am seeing some code periodically crash (or hang) when I run it under purify. I have distilled it down to a test case and it appears to consistently crash (or hang) on the call to std::string::replace(). Has anyone one seen an issue like this before?

Environment:
MSVC 2008 (I have also tried VC 2005 and VC 2010)

Purify Version:
Purify Windows,
(C) Copyright IBM Corporation. 1992, 2012. All Rights Reserved.
Version 7.0.1.0-003 32-bit build 20120410.1500

Test Case:

#include <iostream>
#include <string>
#include <vector>

int
main()
{
std::string stmt("INSERT INTO CLBSRITTE12004 VALUES ( ?, ?, ?, ? )");
size_t stmtLength = stmt.length() - 3;

std::vector<std::string> columnsAsString;

// 40,043 A's + 1 B
std::string col2(40043, 'A');
col2 += 'B';
stmtLength += col2.length();

// 40,000 A's + 1 B
std::string col3(40000, 'A');
col3 += 'A';
stmtLength += col3.length();

std::string col4("-1");
stmtLength += col4.length();

columnsAsString.push_back(col4);
columnsAsString.push_back(col3);
columnsAsString.push_back(col2);
// re-use col1 value
columnsAsString.push_back(col4);

std::string newStmt(stmt);
newStmt.reserve(stmtLength);

size_t index = columnsAsString.size() - 1;
size_t length = newStmt.length() - 1;

for (size_t i = 0; i < length; ++i) {
if (newStmtlength - i == '?') {
newStmt.replace(length - i, 1, columnsAsStringindex);
--index;
}
}

return 0;
}

If I run this executable multiple times in a row (about 500 times) it will crash several times within those iterations with this error:
Problem signature:
Problem Event Name: APPCRASH
Application Name: t1$Purify_C_Workspace_build__32_examples.exe
Application Version: 0.0.0.0
Application Timestamp: 501fe458
Fault Module Name: PURERT.DLL
Fault Module Version: 7.0.1.0
Fault Module Timestamp: 4f84b0af
Exception Code: c0000005
Exception Offset: 00067224
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: c4ee
Additional Information 2: c4ee6400be4bc61047c5c4cd2d8c23ce
Additional Information 3: 9160
Additional Information 4: 9160db0918117b0ac11f33519856b780

If anyone has seen this error or has any advice, your help would be greatly appreciated.

Thanks!
Dave Ritter