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_QueryCallback(void *, int, char **, char **)>, 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 FIRMEN_Activate (pActiv=0x2753aa8, inx=2)
    at ../sources/1_start/mod_firmen.cpp:175
#12 0x004c69b7 in FIRMEN_Message (pActiv=0x2753aa8, pEvent=0x27c2e28)
    at ../sources/1_start/mod_firmen.cpp:314
#13 0x6bb11edd in ACTIV::ACTIV_ProcessMessage (this=0x2753aa8,
    bForwardToWindow=true, pEvent=0x27c2e28) at
../sources/obj_active.cpp:4375
#14 0x6bb11187 in ACTIV::ACTIV_ActivProcedure (this=0x2753aa8,
    system=0xe35120, window=0xe36b78, activ=0x2753aa8, hwnd=0x6808a2,
    message=78, wParam=2, lParam=2281696) at ../sources/obj_active.cpp:4035
#15 0x6bb067f9 in ActivProcedure (hwnd=0x6808a2, message=78, wParam=2,
    lParam=2281696) at ../sources/obj_active.cpp:39
#16 0x7e368734 in _libws2_32_a_iname ()

<---------- SNIP

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

Reply via email to