Access Violation in either push_back()

S

Shawn

Hello,

I'm getting a fairly reproducible Access Violation error when I call
the std::Vector.push_back() function on a CString. It's my current
guess that I'm corrupting memory somewhere else (possibly) and it's
effecting this line of code. Does anyone have any suggestions as to
how to approach this issue? One more thing, the error is often an
Access Violation but sometimes it says something about HEAP
corruption. Also, this is just the latest incarnation of this code, I
have also tried a version that just concatenate CStrings and another
version that concatenated std::strings with equally confusing errors.
Any ideas? Thanks folks.

-S. Cook

Here is the VS 6.0 debug output:
First-chance exception in TempleInland.exe (NTDLL.DLL): 0xC0000005:
Access Violation.
First-chance exception in TempleInland.exe (KERNEL32.DLL): 0xE06D7363:
Microsoft C++ Exception.

And the callstack:
KERNEL32! 7c812a5b()
MSVCRTD! _CxxThrowException@8 + 57 bytes
AfxThrowMemoryException() line 314
AfxNewHandler(unsigned int 1024) line 281
operator new(unsigned int 1024) line 338 + 13 bytes
std::_Allocate(int 256, CString * 0x00000000 {???}) line 30 + 12 bytes
std::allocator<CString>::allocate(unsigned int 256, const void *
0x00000000) line 59 + 40 bytes
std::vector<CString,std::allocator<CString> >::insert(CString *
0x00888350 {""}, unsigned int 1, const CString &
{"1*,*59000*,*04/15/2008 17:29:33 PM*n*"}) line 158 + 14 bytes
std::vector<CString,std::allocator<CString> >::insert(CString *
0x00888350 {""}, const CString & {"1*,*59000*,*04/15/2008 17:29:33
PM*n*"}) line 154
std::vector<CString,std::allocator<CString> >::push_back(const CString
& {"1*,*59000*,*04/15/2008 17:29:33 PM*n*"}) line 142 + 50 bytes
DBconnect::Get_Kicks(CString {"1"}, CString {"4/15/2008 1:00:00 PM"},
unsigned int 0) line 1011
DBconnect::handleClientRequest(CString {"Kicks,1,4/15/2008 1:00:00
PM"}, unsigned int 0) line 1379
DBconnect::StartChecking() line 1635
DBThread(void * 0x00882da0) line 40
_AfxThreadEntry(void * 0x0012fd9c) line 112 + 13 bytes
_threadstartex(void * 0x00882100) line 212 + 13 bytes
KERNEL32! 7c80b683()


Here is the code where it is occuring:
void DBconnect::Get_Kicks(CString machineID, CString tmpTimeStamp,
unsigned int clientIndex)
{
stringVector rowData;
CString cell;
rsKicks rs;
CString query, mID, kicks, time;
CString delim = "*,*";
CString rowDelim = "*n*";
char b1[128] = {0};
char b2[128] = {0};

query = "SELECT * From Kicks WHERE MachineID = " + machineID + " AND
TimeStamp >= #" + tmpTimeStamp + "# " +
"ORDER BY TimeStamp";

rs.Open(CRecordset::snapshot, _T( query ));

if (rs.IsOpen())
{
if (kicksTableLocked)
printf("Get Kicks-----------------locked");
else
{

kicksTableLocked = true;
printf("LOCKED GET KICKS\n");
EnterCriticalSection (&cs_clientRequestLists);



cell = "";
while(!rs.IsEOF())
{
mID = itoa(rs.m_MachineID,b1,10); //0
kicks = itoa(rs.m_Kicks, b2, 10); //1
time = FormatTime(rs.m_TimeStamp); //2
cell =
mID + delim +
kicks + delim +
time + "*n*";
rowData.push_back(cell);<--********************* CRASHES HERE
*************************

rs.MoveNext();
}
rs.Close();



clientDataBuffer_list[clientIndex].push_back(rowData);

//flag the client's data as ready
clientDataReady_list.at(clientIndex)=true;

LeaveCriticalSection (&cs_clientRequestLists);

kicksTableLocked = false;
printf("UNLOCKED GET KICKS\n");

}
}

else
printf("DBconnect::Get_Kicks - Failed to Open Kicks Table\n");

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top