这是在双核32位Vista机器上的Visual Studio 2008上.在调试代码中运行正常,但在发布模式下这个炸弹:
void getFromDB(vector<string>& dates) {
...
sql::Resultset res = stmt->executeQuery("SELECT FROM ...");
while (res->next()) {
string date = res->getString("date");
dates.push_back(date);
} // <<< crashing here (line 56)
delete res;
}
Run Code Online (Sandbox Code Playgroud)
MySQL C++连接器在它的ResultSet中有这个方法:
virtual std::string getString(const std::string& columnLabel) const = 0;
Run Code Online (Sandbox Code Playgroud)
由于某些原因,在编译版本中(针对MySQL C++连接器DLL),这会在循环结束时因堆损坏而崩溃:
HEAP [sa-ms-release.exe]:为RtlFreeHeap指定的地址无效(024E0000,001C4280)Windows在sa-ms-release.exe中触发了断点.
ntdll.dll!_RtlpBreakPointHeap@4() + 0x28 bytes
ntdll.dll!_RtlpValidateHeapEntry@12() + 0x713e8 bytes
ntdll.dll!_RtlDebugFreeHeap@12() + 0x9a bytes
ntdll.dll!@RtlpFreeHeap@16() + 0x145cf bytes
ntdll.dll!_RtlFreeHeap@12() + 0xed5 bytes
kernel32.dll!_HeapFree@12() + 0x14 bytes
> sa-ms-release.exe!free(void * pBlock=0x001c4280) Line 110 C
sa-ms-release.exe!std::allocator<char>::deallocate(char * _Ptr=0x001c4280, …Run Code Online (Sandbox Code Playgroud)