Hi,

I am consistently observing this error in Linux envrionment.  
I have sqlite3 library linked with my DLL. The program links/loads my DLL as 
well as a second DLL which includes the code to open and close db connections. 

Wondering what can be wrong.

Below is description:

sqlite3 *db;
 
1) I open a db connection by sqlite3_open("db-name", &db);

2) I query a row from database by using sqlite3_exec( ).

3) The row data is processed in the callback function called by sqlite3_exec(). 
 I pass a pointer to the callback function and allocate several chunks of 
memory using calloc.

4) Then I try to close the db connection by calling sqlite3_close().  During 
the close operation I get General Protection Error and the rsp is pointing to 
the address near the db handle.

Below is trace log:   
NOTE:  sqlite3 *db = NULL;

Before calling sqlite3_open():
db = (nil), &db = 0x7fffa7e02438

After calling sqlite3_open("db-name", &db):
 db = 0x672f10, &db = 0x7fffa7e02438

n = sqlite3_exec(db, "select * from table-name;", callback_mem, ptr, &db_err);
if (n != SQLITE_OK) {              
                return ERROR; }

The sqlite3_exec doesn't fail and the callback function "callback_mem()" is 
called with the value of ptr.
As there is ONLY one row, callback_mem( ) is called ONLY once.

In the callback_mem( ) I allocated several chunks of memory in the structure 
pointed to by *ptr.

After completing the sqlite3_exec (), before calling sqlite3_close():
db = 0x672f10, &db = 0x7fffa7e02438

sqlite3_close(db);
 general protection rip:2ad90420a7ed rsp:7fffa7e022e0 error:0
[1]+  Segmentation fault      /usr/bin/aim_cp_main.bin
bash-3.00#

NOTE: the value of rsp.

Also, I must mention that if I call a different callback function which doesn't 
do many calloc() etc.  I don't see this error.


Any pointer and/or ideas will be very helpful. 



Sincerely,
Zaryab
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to