If MEM_STATUS is disabled, avoid holding the STATIC_MEM mutex when calling the user-defined xMalloc method. Holding the mutex causes problems for memsys3 and memsys5.

FossilOrigin-Name: 4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8
This commit is contained in:
dan 2010-09-02 10:08:41 +00:00
parent 659503a18d
commit b0c6a8884b
4 changed files with 15 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\sfew\stypos.\s\sUpdate\sevidence\smarks.
D 2010-09-02T04:30:19
C If\sMEM_STATUS\sis\sdisabled,\savoid\sholding\sthe\sSTATIC_MEM\smutex\swhen\scalling\sthe\suser-defined\sxMalloc\smethod.\sHolding\sthe\smutex\scauses\sproblems\sfor\smemsys3\sand\smemsys5.
D 2010-09-02T10:08:41
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -139,7 +139,7 @@ F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 6d422ea91cf3d2d00408c5a8f2391cd458da85f8
F src/main.c b92c6c9a302999975897730b2808708fbf531a56
F src/malloc.c d9fcf07f366a29d45d4c3157323074578912b83c
F src/malloc.c 8b67cb6ba7853ad166fd6909ca5f702bf063c053
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206
F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf
@ -555,7 +555,7 @@ F test/pageropt.test 8146bf448cf09e87bb1867c2217b921fb5857806
F test/pagesize.test 76aa9f23ecb0741a4ed9d2e16c5fa82671f28efb
F test/pcache.test 4118a183908ecaed343a06fcef3ba82e87e0129d
F test/pcache2.test 0d85f2ab6963aee28c671d4c71bec038c00a1d16
F test/permutations.test fff338765bb6d9235d385ead4e6d5c9433b6ba05
F test/permutations.test 9c73c6524ad0603b9f6ab3d49c77ac5a94919732
F test/pragma.test ed78d200f65c6998df51196cb8c39d5300570f24
F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
F test/printf.test 05970cde31b1a9f54bd75af60597be75a5c54fea
@ -853,7 +853,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 47064453c396d5204a851b8ec08d665e2b12228a
R 5316ca78a31d0600ba648eb3697b1628
U shaneh
Z fd2dbfe354669eca2760f91876afbc58
P c90a68b77e03bb351a7781f1b9dea38f5f571dcf
R 8ea9ea167aeaca9c298d5f0ede771876
U dan
Z d79bb8b6ec3d7a429b2e5218ed3eb161

View File

@ -1 +1 @@
c90a68b77e03bb351a7781f1b9dea38f5f571dcf
4f20f8ba73691c8a1dc33d2fcd1e793dd08f00a8

View File

@ -352,17 +352,21 @@ void *sqlite3ScratchMalloc(int n){
mem0.nScratchFree--;
sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
sqlite3_mutex_leave(mem0.mutex);
}else{
if( sqlite3GlobalConfig.bMemstat ){
sqlite3StatusSet(SQLITE_STATUS_SCRATCH_SIZE, n);
n = mallocWithAlarm(n, &p);
if( p ) sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, n);
sqlite3_mutex_leave(mem0.mutex);
}else{
sqlite3_mutex_leave(mem0.mutex);
p = sqlite3GlobalConfig.m.xMalloc(n);
}
sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
}
sqlite3_mutex_leave(mem0.mutex);
assert( !sqlite3_mutex_held(mem0.mutex) );
#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
/* Verify that no more than two scratch allocations per thread

View File

@ -587,6 +587,7 @@ ifcapable mem5 {
} -initialize {
catch {db close}
sqlite3_shutdown
sqlite3_config_memstatus 0
sqlite3_config_heap 40000000 16
sqlite3_config_lookaside 0 0
install_malloc_faultsim 1