Re: [sqlite] sqlite-amalgamation + own functions = Segmentation fault at "sqlite3VdbeMemSetStr" sice version 3.7.5 (to v3.7.3 works fine)
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 04/15/2011 06:28 AM, Jaromir Prinzler wrote: > I use SQLite Amalgamation and compile it with gcc 2.95 under windows xp. I strongly recommend you get a more recent version of the compiler. MinGW now has a decent automated installed and you'll get GCC 4.5. >SQLITE_MAX_LENGTH=10 <--- I have long > BLOBS >SQLITE_MAX_SQL_LENGTH=10 <--- I have long BLOBS Those are the default values anyway. You should only need such long SQL for blobs if you are avoiding the sqlite3_bind_blob api. You *really* should use that api. >SQLITE_THREADSAFE=0<--- I have > testet > with this option. The result are the same ;-( If you use anything other than the default SQLITE_THREADSAFE setting then then the onus is on you to prove that you haven't messed up threading anywhere. (Just claiming that you don't isn't sufficient - prove it.) > Since SQLite version 3.7.5 crash my code on For this sort of thing by far the most productive way of finding the problems is to get the code to run on Linux and then use valgrind. If you can't do that then you'll need to slog the less productive tools under Windows. Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2qA1oACgkQmOOfHg372QS7QACgup11M5auCcP/BbOfRGnvmjMW tSkAnj9RzufhtMp42xw9MhmFb7CcsIhr =ut7G -END PGP SIGNATURE- ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] sqlite-amalgamation + own functions = Segmentation fault at "sqlite3VdbeMemSetStr" sice version 3.7.5 (to v3.7.3 works fine)
Care to show us your SPL_mallocstr() function? Sounds like you've corrupted data if that line dies. All it's doing is checking an array value which is used all over the place in sqlite3.c If you put a break point there and on the first time it's hit put a watch on the address for u.ao.nByte>db->aLimit then you may be able too see where it's getting smashed. Or try dmalloc or whatever checker you have for BSD. Michael D. Black Senior Scientist NG Information Systems Advanced Analytics Directorate From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Jaromir Prinzler [jprinz...@tplan-gmbh.de] Sent: Friday, April 15, 2011 8:28 AM To: sqlite-users@sqlite.org Subject: EXT :[sqlite] sqlite-amalgamation + own functions = Segmentation fault at "sqlite3VdbeMemSetStr" sice version 3.7.5 (to v3.7.3 works fine) Hello ! I hope you can understand my bad english ;-) Since a long time i use sqlite for my projects. Now i have updated from SQLite v3.7.3 over SQLite v3.7.5 to SQLite 3.7.6. I use SQLite Amalgamation and compile it with gcc 2.95 under windows xp. Compiling options for "Amalgamation" are : SQLITE_MAX_LENGTH=1 000 000 000 <--- I have long BLOBS SQLITE_MAX_SQL_LENGTH=1 00 000 000 <--- I have long BLOBS SQLITE_MAX_EXPR_DEPTH=0 SQLITE_THREADSAFE=0 <--- I have testet with this option. The result are the same ;-( The binding to my cpp object follows dynamic (LoadLibrary, GetProc and so on..) I have defined many own SQL functions for SQLite. TRIM() is one of them. Since SQLite version 3.7.5 crash my code on "sqlite3VdbeMemSetStr" on line 56539 on sqlite3.c from sqlite-amalgamation (v3.7.6.1). This codelines have follow content: SNIP --> if( pMem->db ){ iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH]; // <-- THIS LINE IS 56539 }else{ iLimit = SQLITE_MAX_LENGTH; } <-- SNIP The Sample TRIM() SQL function is... (PRC_... calls are dynamically loaded pointer from sqlite3.dll) SNIP --> void SQLITEFUNC_trim(sqlite3_context *pContext, int argc, sqlite3_value **argv) { char *buf = NULL; if(argc == 1) { switch(PRC_SQLITE3_VALUE_TYPE(argv[0])) { case SQLITE_TEXT:buf = SPL_mallocstr(SPL_StrTrim((char *) PRC_SQLITE3_VALUE_TEXT(argv[0]))); break; // < SPL_xxx are my functions to convert anything to string case SQLITE_FLOAT: buf = SPL_mallocstr(SPL_DoubleToAsci("%f", PRC_SQLITE3_VALUE_DOUBLE(argv[0]))); break; case SQLITE_INTEGER: buf = SPL_mallocstr(SPL_IntegerToAsci("%d", PRC_SQLITE3_VALUE_INT(argv[0]))); break; case SQLITE_BLOB:break; case SQLITE_NULL:buf = SPL_mallocstr(""); // < I need this ! break; } } if(!buf) { <--- Error Handler removed > return; } PRC_SQLITE3_RESULT_TEXT(pContext, buf, -1, SPL_free); } <-- SNIP "SPL_mallocstr" and "SPL_free" are equal to malloc and free. "SPL_mallocstr" makes a good string with '\0' at the end. I hope you can understand me and haves hints for me or you can make a bug-ticket ? Thanxs for your help. A nice weekend and greetings from berlin/germany. Jaromir Prinzler SNIP --> Gdb (the debugger produce the output) Program received signal SIGSEGV, Segmentation fault. 0x6092811d in sqlite3VdbeMemSetStr (pMem=0x22be58, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4 <SPL_free(void *)>) at ../sources/sqlite3.c:56539 56539 ../sources/sqlite3.c: No such file or directory. in ../sources/sqlite3.c (gdb) bt #0 0x6092811d in sqlite3VdbeMemSetStr (pMem=0x22be58, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4 <SPL_free(void *)>) at ../sources/sqlite3.c:56539 #1 0x6092d6fc in setResultStrOrError (pCtx=0x22be50, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4 <SPL_free(void *)>) at ../sources/sqlite3.c:60398 #2 0x6092d85c in sqlite3_result_text (pCtx=0x22be50, z=0x27b0ae8 "", n=-1, xDel=0x6bb5acd4 <SPL_free(void *)>) at ../sources/sqlite3.c:60447 #3 0x6bb7a5de in SQLITEFUNC_trim (pContext=0x22be50, argc=1, argv=0x27af538) at ../sources/spl_database.cpp:409 #4 0x60931273 in sqlite3VdbeExec (p=0x27b3040) at ../sources/sqlite3.c:63587 #5 0x6092dbd1 in sqlite3Step (p=0x27b3040) at ../sources/sqlite3.c:60613 #6 0x6092ddac in sqlite3_step (pStmt=0x27b3040) at ../sources/sqlite3.c:60680 #7 0x6095492c in sqlite3_exec (db=0x27250d0, zSql=0x27ba008 "SELECT basis_adressen.lnr, TRIM(CONCAT(basis_adressen.organisation,'\n\n',TRIM(basis_adressen.strasse || '\n' || TRIM(basis_laender.kuerzel || '-' || basis_adressen.plz || ' ' || basis_adressen.ort) || '"..., xCallback=0x6ba90f30 <DATABASE_SQLite_QueryCall
[sqlite] sqlite-amalgamation + own functions = Segmentation fault at "sqlite3VdbeMemSetStr" sice version 3.7.5 (to v3.7.3 works fine)
Hello ! I hope you can understand my bad english ;-) Since a long time i use sqlite for my projects. Now i have updated from SQLite v3.7.3 over SQLite v3.7.5 to SQLite 3.7.6. I use SQLite Amalgamation and compile it with gcc 2.95 under windows xp. Compiling options for "Amalgamation" are : SQLITE_MAX_LENGTH=10 <--- I have long BLOBS SQLITE_MAX_SQL_LENGTH=10 <--- I have long BLOBS SQLITE_MAX_EXPR_DEPTH=0 SQLITE_THREADSAFE=0 <--- I have testet with this option. The result are the same ;-( The binding to my cpp object follows dynamic (LoadLibrary, GetProc and so on..) I have defined many own SQL functions for SQLite. TRIM() is one of them. Since SQLite version 3.7.5 crash my code on "sqlite3VdbeMemSetStr" on line 56539 on sqlite3.c from sqlite-amalgamation (v3.7.6.1). This codelines have follow content: SNIP --> if( pMem->db ){ iLimit = pMem->db->aLimit[SQLITE_LIMIT_LENGTH]; // <-- THIS LINE IS 56539 }else{ iLimit = SQLITE_MAX_LENGTH; } <-- SNIP The Sample TRIM() SQL function is... (PRC_... calls are dynamically loaded pointer from sqlite3.dll) SNIP --> void SQLITEFUNC_trim(sqlite3_context *pContext, int argc, sqlite3_value **argv) { char *buf = NULL; if(argc == 1) { switch(PRC_SQLITE3_VALUE_TYPE(argv[0])) { case SQLITE_TEXT:buf = SPL_mallocstr(SPL_StrTrim((char *) PRC_SQLITE3_VALUE_TEXT(argv[0]))); break; // < SPL_xxx are my functions to convert anything to string case SQLITE_FLOAT: buf = SPL_mallocstr(SPL_DoubleToAsci("%f", PRC_SQLITE3_VALUE_DOUBLE(argv[0]))); break; case SQLITE_INTEGER: buf = SPL_mallocstr(SPL_IntegerToAsci("%d", PRC_SQLITE3_VALUE_INT(argv[0]))); break; case SQLITE_BLOB:break; case SQLITE_NULL:buf = SPL_mallocstr(""); // < I need this ! break; } } if(!buf) { <--- Error Handler removed > return; } PRC_SQLITE3_RESULT_TEXT(pContext, buf, -1, SPL_free); } <-- SNIP "SPL_mallocstr" and "SPL_free" are equal to malloc and free. "SPL_mallocstr" makes a good string with '\0' at the end. I hope you can understand me and haves hints for me or you can make a bug-ticket ? Thanxs for your help. A nice weekend and greetings from berlin/germany. Jaromir Prinzler SNIP --> Gdb (the debugger produce the output) Program received signal SIGSEGV, Segmentation fault. 0x6092811d in sqlite3VdbeMemSetStr (pMem=0x22be58, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4) at ../sources/sqlite3.c:56539 56539 ../sources/sqlite3.c: No such file or directory. in ../sources/sqlite3.c (gdb) bt #0 0x6092811d in sqlite3VdbeMemSetStr (pMem=0x22be58, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4 ) at ../sources/sqlite3.c:56539 #1 0x6092d6fc in setResultStrOrError (pCtx=0x22be50, z=0x27b0ae8 "", n=-1, enc=1 '\001', xDel=0x6bb5acd4 ) at ../sources/sqlite3.c:60398 #2 0x6092d85c in sqlite3_result_text (pCtx=0x22be50, z=0x27b0ae8 "", n=-1, xDel=0x6bb5acd4 ) at ../sources/sqlite3.c:60447 #3 0x6bb7a5de in SQLITEFUNC_trim (pContext=0x22be50, argc=1, argv=0x27af538) at ../sources/spl_database.cpp:409 #4 0x60931273 in sqlite3VdbeExec (p=0x27b3040) at ../sources/sqlite3.c:63587 #5 0x6092dbd1 in sqlite3Step (p=0x27b3040) at ../sources/sqlite3.c:60613 #6 0x6092ddac in sqlite3_step (pStmt=0x27b3040) at ../sources/sqlite3.c:60680 #7 0x6095492c in sqlite3_exec (db=0x27250d0, zSql=0x27ba008 "SELECT basis_adressen.lnr, TRIM(CONCAT(basis_adressen.organisation,'\n\n',TRIM(basis_adressen.strasse || '\n' || TRIM(basis_laender.kuerzel || '-' || basis_adressen.plz || ' ' || basis_adressen.ort) || '"..., xCallback=0x6ba90f30 , pArg=0x27c2 e70, pzErrMsg=0x22c108) at ../sources/sqlite3.c:20714 #8 0x6ba9f8aa in DATABASE::DATABASE_Query (this=0xe3b4c8, pszQuery=0x27ba008 "SELECT basis_adressen.lnr, TRIM(CONCAT(basis_adressen.organisation,'\n\n',TRIM(basis_adressen.strasse || '\n' || TRIM(basis_laender.kuerzel || '-' || basis_adressen.plz || ' '|| basis_adressen.ort) || '"...) at ../sources/obj_database.cpp:3404 #9 0x6baa003f in DATABASE::DATABASE_RowQuery (this=0xe3b4c8, pszQuery=0x27ba008 "SELECT basis_adressen.lnr, TRIM(CONCAT(basis_adressen.organisation,'\n\n',TR IM(basis_adressen.strasse || '\n' || TRIM(basis_laender.kuerzel || '-' || basis_adressen.plz || ' '|| basis_adressen.ort) || '"...) at ../sources/obj_database.cpp:3571 #10 0x6baa0204 in DATABASE::DATABASE_RowQueryEx (this=0xe3b4c8, pszQuery=0x4c504c "SELECT basis_adressen.lnr, TRIM(CONCAT(basis_adressen.organisation,'\n\n',TRI M(basis_adressen.strasse || '\n' || TRIM(basis_laender.kuerzel || '-' || basis_adressen.plz || ' ' || basis_adressen.ort) || '"...) at ../sources/obj_database.cpp:3626 #11 0x004c65cb in