Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Access Violation in either push_back()

Reply
Thread Tools

Access Violation in either push_back()

 
 
Shawn
Guest
Posts: n/a
 
      04-16-2008
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> >:ush_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");

}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone successfully using Ruby to access a Sybase database(either DBIor SQLAnywhere gem) kevin.scott.02@gmail.com Ruby 2 04-04-2013 04:33 PM
Access Violation error while saving config from PIX through PDM toa TFTP server. AM Cisco 4 10-10-2006 07:59 PM
Setting a connection string to connect to either Access or Sql Ser Jack ASP General 2 10-06-2005 08:14 PM
ASP.NET and managed C++: Access violation when AppDomain is unloaded. F. Prefect ASP .Net 5 10-10-2004 08:15 AM
ASP.NET and managed C++: Access violation when AppDomain is unloaded. news ASP .Net 0 10-06-2004 06:51 AM



Advertisments