EXC_BAD_ACCESS after query.storein()
Posted by:
Alan Shank
Date: February 03, 2011 03:52PM
My code, which works fine in Linux (Ubuntu 10.10) looks like this:
Connection conn(false);
conn.connect(db, server, user, pass)
Transaction trans(conn);
Query query = conn.query("Update blah blah");
query.execute(); // inside try,catch,catch block
query << "Another update";
query.execute(); //try
query << "Yet another";
query.execute; //try
trans.commit();
query << "select this, that and the other thing";
vector<deepskyStruct> resvec; // deepskyStruct is an ssqls structure
query.storein(resvec);
vector<deepskyStruct>::iterator it;
for loop through the vector, creating members of class SessionObject from the data
end for
start another transaction
query << "Update a different table";
query.execute(); //two more of these
trans2.commit();
query << "Select blah, blah blah from a different table";
vector(doubleStarStruct> resvec2;
//Up to here, everything is fine, and I have verified that all the updates took place. I also know that the first select, storing in resvec, creating the objects, etc. worked, because when I commented out the stuff for the 2nd table the program completed successfully with the expected output.
query.storein(resvec2);
Then:
402 query.storein(resvec2);
(gdb) next
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000041c
0x93d12a8d in std::string::clear ()
The address of resvec2 was 0xbfffefdc, while the address of resvec was 0xbfffefb0 or sth in that neighborhood.
Any help appreciated.
Thanks,
Alan Shank
Woodland, CA