이것은 Visual Studio 2008의 듀얼 코어 32 비트 Vista 시스템입니다.벡터에 문자열을 추가 할 때 메모리가 손상됩니다. <string> 루프
virtual std::string getString(const std::string& columnLabel) const = 0;
컴파일 된 버전에서 어떤 이유 (대한이 잘 실행하지만 릴리스 모드에서 디버그 코드에서 이 폭탄 : 그것은 ResultSet의의에
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;
}
MySQL의 C++ 커넥터는이 방법이 있습니다
HEAP [SA-MS-release.exe] : RtlFreeHeap (024E0000, 001C4280에 지정된 잘못된 주소) 01,235,164 MySQL의 C++ 커넥터 DLL) 이것은 힙 손상과 루프의 끝에서 충돌Windows에서 sa-ms-release.exe에서 중단 점을 트리거했습니다.
[email protected]() + 0x28 bytes
[email protected]() + 0x713e8 bytes
[email protected]() + 0x9a bytes
[email protected]@16() + 0x145cf bytes
[email protected]() + 0xed5 bytes
[email protected]() + 0x14 bytes
> sa-ms-release.exe!free(void * pBlock=0x001c4280) Line 110 C
sa-ms-release.exe!std::allocator<char>::deallocate(char * _Ptr=0x001c4280, unsigned int __formal=32) Line 140 + 0x9 bytes C++
sa-ms-release.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Tidy(bool _Built=true, unsigned int _Newsize=0) Line 2158 C++
sa-ms-release.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >() Line 907 C++
sa-ms-release.exe!StyleData:: getFromDB(std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > & dates) Line 56 + 0x69 bytes C++
나는 내가 벡터 내부에 보존 할 문자열에 호출 할 소멸자 원인이 몇 가지 기본적인 C++ 규칙을 위반 할 수있다 생각합니다.
내가
string date = string ("2008-11-23");
모든 것을
string date = res->getString("date")
교체 할 경우 잘 작동합니다. MySQL C++ Connector getString() 메서드에서 반환 된 문자열과 관련이있는 것으로 보입니다. 반환 된 문자열이 파손되어 문제가 발생합니다. 하지만 다른 가능성이 더 높습니다. MySQL Connector를 사용하고 있습니다.
컴파일 대상 STL 버전, SDK 또는 VS? – vpram86
코드에 줄 번호를 넣으면 도움이 될 수 있습니다 (위 메시지의 마지막 줄은 StyleData :: getFromDB의 56 번째 줄을 지정합니다). Disassebly 더 많은 도움이 될 수도 있습니다 ... – Tomek
sql :: Resultset :: getString (...); –