mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Added an assert() to detect lookaside memory leaks. Also added the
SQLITE_OMIT_LOOKASIDE compile-time option which is useful in trying to track down lookaside memory leaks. (CVS 5800) FossilOrigin-Name: 0c4c66071a46cecc5f87afb8f8f01ae2c90ee9b3
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fix\san\sassertion\sfault\sthat\soccurs\swith\sSQLITE_THREADSAFE=0.\s(CVS\s5799)
|
C Added\san\sassert()\sto\sdetect\slookaside\smemory\sleaks.\s\sAlso\sadded\sthe\nSQLITE_OMIT_LOOKASIDE\scompile-time\soption\swhich\sis\suseful\sin\strying\sto\ntrack\sdown\slookaside\smemory\sleaks.\s(CVS\s5800)
|
||||||
D 2008-10-11T15:20:05
|
D 2008-10-11T15:38:30
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in 7fc26e087207e7a4a7723583dbd7997477af3b13
|
F Makefile.in 7fc26e087207e7a4a7723583dbd7997477af3b13
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@@ -118,8 +118,8 @@ F src/insert.c 110cca7845ed5a66c08fdd413b02e706ae34455f
|
|||||||
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
|
F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
|
||||||
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
|
F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
|
||||||
F src/loadext.c cadd5df14bcda5ef0c26d815eb609a755861923e
|
F src/loadext.c cadd5df14bcda5ef0c26d815eb609a755861923e
|
||||||
F src/main.c eca6e80598aeccb58f722c2f1c0f25ee6b442c16
|
F src/main.c 479e3b64066ac58d9957795608b0950425877f5f
|
||||||
F src/malloc.c 31f4ca218f4b664dce45ef9c4f1fcd2929c67a42
|
F src/malloc.c 20613ebf4664dec6eb47f62d76264b24ee2a7e4a
|
||||||
F src/mem1.c 5a529ff121c55ab067be14de00f86f6dcc4f4fb9
|
F src/mem1.c 5a529ff121c55ab067be14de00f86f6dcc4f4fb9
|
||||||
F src/mem2.c f87e681d0d1ed8436870d089332ed0d27d885b5c
|
F src/mem2.c f87e681d0d1ed8436870d089332ed0d27d885b5c
|
||||||
F src/mem3.c 1594f117fde4cf11a6c16521f3f30af8d04bbe68
|
F src/mem3.c 1594f117fde4cf11a6c16521f3f30af8d04bbe68
|
||||||
@@ -648,7 +648,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P fab4940d54fd1e5459a3d0d9b64b491e6972fd8d
|
P 28bba42b338afd63e1dad9f431d631f6f3027275
|
||||||
R 8cb8a1748def7de0b4ac00aa033b0078
|
R 74f64a08ff5ef738b9c92d4ed58f474f
|
||||||
U drh
|
U drh
|
||||||
Z 6d1bf3ab78bfeca6642c5036493454fe
|
Z 24abcbe1839acd523ab8a8985b39233b
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
28bba42b338afd63e1dad9f431d631f6f3027275
|
0c4c66071a46cecc5f87afb8f8f01ae2c90ee9b3
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: main.c,v 1.506 2008/10/11 15:20:05 drh Exp $
|
** $Id: main.c,v 1.507 2008/10/11 15:38:30 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -635,6 +635,7 @@ int sqlite3_close(sqlite3 *db){
|
|||||||
sqlite3_mutex_leave(db->mutex);
|
sqlite3_mutex_leave(db->mutex);
|
||||||
db->magic = SQLITE_MAGIC_CLOSED;
|
db->magic = SQLITE_MAGIC_CLOSED;
|
||||||
sqlite3_mutex_free(db->mutex);
|
sqlite3_mutex_free(db->mutex);
|
||||||
|
assert( db->lookaside.nOut==0 ); /* Fails on a lookaside memory leak */
|
||||||
if( db->lookaside.bMalloced ){
|
if( db->lookaside.bMalloced ){
|
||||||
sqlite3_free(db->lookaside.pStart);
|
sqlite3_free(db->lookaside.pStart);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
**
|
**
|
||||||
** Memory allocation functions used throughout sqlite.
|
** Memory allocation functions used throughout sqlite.
|
||||||
**
|
**
|
||||||
** $Id: malloc.c,v 1.42 2008/09/23 16:41:30 danielk1977 Exp $
|
** $Id: malloc.c,v 1.43 2008/10/11 15:38:30 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -485,9 +485,13 @@ void sqlite3PageFree(void *p){
|
|||||||
/*
|
/*
|
||||||
** TRUE if p is a lookaside memory allocation from db
|
** TRUE if p is a lookaside memory allocation from db
|
||||||
*/
|
*/
|
||||||
|
#ifndef SQLITE_OMIT_LOOKASIDE
|
||||||
static int isLookaside(sqlite3 *db, void *p){
|
static int isLookaside(sqlite3 *db, void *p){
|
||||||
return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;
|
return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#define isLookaside(A,B) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the size of a memory allocation previously obtained from
|
** Return the size of a memory allocation previously obtained from
|
||||||
@@ -617,6 +621,7 @@ void *sqlite3DbMallocZero(sqlite3 *db, int n){
|
|||||||
*/
|
*/
|
||||||
void *sqlite3DbMallocRaw(sqlite3 *db, int n){
|
void *sqlite3DbMallocRaw(sqlite3 *db, int n){
|
||||||
void *p;
|
void *p;
|
||||||
|
#ifndef SQLITE_OMIT_LOOKASIDE
|
||||||
if( db ){
|
if( db ){
|
||||||
LookasideSlot *pBuf;
|
LookasideSlot *pBuf;
|
||||||
if( db->mallocFailed ){
|
if( db->mallocFailed ){
|
||||||
@@ -632,6 +637,7 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){
|
|||||||
return (void*)pBuf;
|
return (void*)pBuf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
p = sqlite3Malloc(n);
|
p = sqlite3Malloc(n);
|
||||||
if( !p && db ){
|
if( !p && db ){
|
||||||
db->mallocFailed = 1;
|
db->mallocFailed = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user