[sqlite] sqlite3DbMallocRaw problem

2012-09-09 Thread David Levinson
All,

In the sqlite3DbMallocRaw() function I just encountered a failure where pBuf is 
undefined and causes a crash on db-lookaside.pFree = pBuf-pNext.  I see 
that pBuf is created (not initialized) and then later a check is made for pBuf 
(null) - pNext and poof my app crashes. I have no idea how to replicate this 
issue but it happens randomly why creating prepared statements over and over 
very quickly for many hours but that may just be dumb luck.

LookasideSlot *pBuf;
if( db-mallocFailed ){
  return 0;
}
if( db-lookaside.bEnabled ){
  if( ndb-lookaside.sz ){
db-lookaside.anStat[1]++;
  }else if( (pBuf = db-lookaside.pFree)==0 ){
db-lookaside.anStat[2]++;
  }else{
db-lookaside.pFree = pBuf-pNext;

should I recompile with the SQLITE_OMIT_LOOKASIDE enabled?

Thanks,

Dave.



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


Re: [sqlite] sqlite3DbMallocRaw problem

2012-09-09 Thread David Levinson
All,

I wanted to revise my last email regarding the failure within 
sqlite3DbMallocRaw() ... The point of failure is  db-lookaside.pFree = 
pBuf-pNext; and it appears that pBuf points to an invalid memory location 
since Windows report a memory access violation.  Does anyone know how to 
correct this?

LookasideSlot *pBuf;
if( db-mallocFailed ){
  return 0;
}
if( db-lookaside.bEnabled ){
  if( ndb-lookaside.sz ){
db-lookaside.anStat[1]++;
  }else if( (pBuf = db-lookaside.pFree)==0 ){
db-lookaside.anStat[2]++;
  }else{
db-lookaside.pFree = pBuf-pNext;

should I recompile with the SQLITE_OMIT_LOOKASIDE enabled?

Thanks,

Dave.



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


Re: [sqlite] sqlite3DbMallocRaw problem

2012-09-09 Thread Pavel Ivanov
If pBuf points to an invalid memory it's possible that you use already
closed connection or already finalized statement. Or maybe your
application corrupts SQLite's memory. Try to run your program under a
memory debugger.

Pavel


On Sat, Sep 8, 2012 at 10:11 AM, David Levinson dlevin...@worldnow.com wrote:
 All,

 I wanted to revise my last email regarding the failure within 
 sqlite3DbMallocRaw() ... The point of failure is  db-lookaside.pFree = 
 pBuf-pNext; and it appears that pBuf points to an invalid memory location 
 since Windows report a memory access violation.  Does anyone know how to 
 correct this?

 LookasideSlot *pBuf;
 if( db-mallocFailed ){
   return 0;
 }
 if( db-lookaside.bEnabled ){
   if( ndb-lookaside.sz ){
 db-lookaside.anStat[1]++;
   }else if( (pBuf = db-lookaside.pFree)==0 ){
 db-lookaside.anStat[2]++;
   }else{
 db-lookaside.pFree = pBuf-pNext;

 should I recompile with the SQLITE_OMIT_LOOKASIDE enabled?

 Thanks,

 Dave.



 ___
 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


Re: [sqlite] sqlite3DbMallocRaw problem

2012-09-09 Thread Richard Hipp
On Sat, Sep 8, 2012 at 12:40 PM, David Levinson dlevin...@worldnow.comwrote:

 All,

 In the sqlite3DbMallocRaw() function I just encountered a failure where
 pBuf is undefined and causes a crash on db-lookaside.pFree =
 pBuf-pNext.  I see that pBuf is created (not initialized) and then later
 a check is made for pBuf (null) - pNext and poof my app crashes.


What is the value of pBuf at the time of the crash?  Surely it cannot be
NULL since if it were NULL it would never reach the line on which you are
crashing due to the test 3 lines above.

Are you running with multiple threads?  Have you compiled and configured
your application to be threadsafe?  Are you sure of that?



 I have no idea how to replicate this issue but it happens randomly why
 creating prepared statements over and over very quickly for many hours but
 that may just be dumb luck.

 LookasideSlot *pBuf;
 if( db-mallocFailed ){
   return 0;
 }
 if( db-lookaside.bEnabled ){
   if( ndb-lookaside.sz ){
 db-lookaside.anStat[1]++;
   }else if( (pBuf = db-lookaside.pFree)==0 ){
 db-lookaside.anStat[2]++;
   }else{
 db-lookaside.pFree = pBuf-pNext;

 should I recompile with the SQLITE_OMIT_LOOKASIDE enabled?

 Thanks,

 Dave.



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




-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users