mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Fix a segfault in sqlite3OsLock() (CVS 1525)
FossilOrigin-Name: 51348b82c4d5801091537b80059d770410774905
This commit is contained in:
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
|||||||
C Work\stoward\scombining\sthe\sOP_MakeKey,\sOP_MakeIdxKey,\sand\sOP_MakeRecord\nopcodes\sinto\sone.\s\sThe\swork\sis\sincomplete.\s(CVS\s1524)
|
C Fix\sa\ssegfault\sin\ssqlite3OsLock()\s(CVS\s1525)
|
||||||
D 2004-06-02T01:22:02
|
D 2004-06-02T06:30:16
|
||||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@ -43,7 +43,7 @@ F src/os.h 833b9639720d1602d9bfa4ca69c615ec2bfe625a
|
|||||||
F src/os_common.h 744286a27de55c52f1b18921e8d17abbf7fafc0f
|
F src/os_common.h 744286a27de55c52f1b18921e8d17abbf7fafc0f
|
||||||
F src/os_mac.c b823874690615ace0dd520d3ad1fe8bfd864b7e0
|
F src/os_mac.c b823874690615ace0dd520d3ad1fe8bfd864b7e0
|
||||||
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
|
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
|
||||||
F src/os_unix.c 3dc2868d7ff477323f2eaedda0e05921afb6f124
|
F src/os_unix.c 36682ee5e93c2fdad63ff44f7e10ac7d4a39f746
|
||||||
F src/os_unix.h 426e1480f0847a7f8ba22aa9ac5115520875610b
|
F src/os_unix.h 426e1480f0847a7f8ba22aa9ac5115520875610b
|
||||||
F src/os_win.c 92b51a38437b98d8aa3ac05b57c71e1d1092e5be
|
F src/os_win.c 92b51a38437b98d8aa3ac05b57c71e1d1092e5be
|
||||||
F src/os_win.h 5d41af24caaef6c13a2d8e2399caa1c57d45c84d
|
F src/os_win.h 5d41af24caaef6c13a2d8e2399caa1c57d45c84d
|
||||||
@ -148,7 +148,7 @@ F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1
|
|||||||
F test/tclsqlite.test 853e4372004d209e2ff0d4b0b35c91d4f64cd7d8
|
F test/tclsqlite.test 853e4372004d209e2ff0d4b0b35c91d4f64cd7d8
|
||||||
F test/temptable.test a770ba6308d7f7332fce985086b8e06bed6430c2
|
F test/temptable.test a770ba6308d7f7332fce985086b8e06bed6430c2
|
||||||
F test/tester.tcl fc10520db0d3ce4ef6a8b5ab91bd102fc3f4280a
|
F test/tester.tcl fc10520db0d3ce4ef6a8b5ab91bd102fc3f4280a
|
||||||
F test/thread1.test 53f050d5be6932d9430df7756edd379366508ff6
|
F test/thread1.test 2fd5c10e82434f6b03be77b61fde5a050668abf2
|
||||||
F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2
|
F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2
|
||||||
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
|
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
|
||||||
F test/trans.test 45fa0ed87ee487797ea6a30f3ec298a6618531b9
|
F test/trans.test 45fa0ed87ee487797ea6a30f3ec298a6618531b9
|
||||||
@ -214,7 +214,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
|
|||||||
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
||||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||||
P b53640ed2232aaf173a71636073477d80407d11f
|
P 165d69a04cca719dec2b042117f848f153721a1d
|
||||||
R 65e9a4b0c9422591cc77c047015d1b85
|
R e34294435e363d8121bbbf40938d6dd7
|
||||||
U drh
|
U danielk1977
|
||||||
Z f635685494f9f4de060c8aaaeeb301d1
|
Z cf403c13a566790d4729e792131db901
|
||||||
|
@ -1 +1 @@
|
|||||||
165d69a04cca719dec2b042117f848f153721a1d
|
51348b82c4d5801091537b80059d770410774905
|
@ -61,7 +61,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "os_common.h"
|
#include "os_common.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Here is the dirt on POSIX advisory locks: ANSI STD 1003.1 (1996)
|
** Here is the dirt on POSIX advisory locks: ANSI STD 1003.1 (1996)
|
||||||
** section 6.5.2.2 lines 483 through 490 specify that when a process
|
** section 6.5.2.2 lines 483 through 490 specify that when a process
|
||||||
@ -649,7 +648,6 @@ int sqlite3OsFileSize(OsFile *id, off_t *pSize){
|
|||||||
** available on the host, then an SQLITE_NOLFS is returned.
|
** available on the host, then an SQLITE_NOLFS is returned.
|
||||||
*/
|
*/
|
||||||
int sqlite3OsReadLock(OsFile *id){
|
int sqlite3OsReadLock(OsFile *id){
|
||||||
int rc;
|
|
||||||
return sqlite3OsLock(id, SHARED_LOCK);
|
return sqlite3OsLock(id, SHARED_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +658,6 @@ int sqlite3OsReadLock(OsFile *id){
|
|||||||
** available on the host, then an SQLITE_NOLFS is returned.
|
** available on the host, then an SQLITE_NOLFS is returned.
|
||||||
*/
|
*/
|
||||||
int sqlite3OsWriteLock(OsFile *id){
|
int sqlite3OsWriteLock(OsFile *id){
|
||||||
int rc;
|
|
||||||
return sqlite3OsLock(id, EXCLUSIVE_LOCK);
|
return sqlite3OsLock(id, EXCLUSIVE_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -715,13 +712,14 @@ int sqlite3OsLock(OsFile *id, int locktype){
|
|||||||
(pLock->locktype==SHARED_LOCK || pLock->locktype==RESERVED_LOCK) ){
|
(pLock->locktype==SHARED_LOCK || pLock->locktype==RESERVED_LOCK) ){
|
||||||
assert( locktype==SHARED_LOCK );
|
assert( locktype==SHARED_LOCK );
|
||||||
assert( id->locked==0 );
|
assert( id->locked==0 );
|
||||||
|
assert( pLock->cnt>0 );
|
||||||
id->locked = SHARED_LOCK;
|
id->locked = SHARED_LOCK;
|
||||||
pLock->cnt++;
|
pLock->cnt++;
|
||||||
id->pOpen->nLock++;
|
id->pOpen->nLock++;
|
||||||
goto end_lock;
|
goto end_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.l_len = 1L;
|
lock.l_len = 0L;
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
|
|
||||||
/* If control gets to this point, then actually go ahead and make
|
/* If control gets to this point, then actually go ahead and make
|
||||||
@ -729,7 +727,6 @@ int sqlite3OsLock(OsFile *id, int locktype){
|
|||||||
*/
|
*/
|
||||||
if( locktype==SHARED_LOCK ){
|
if( locktype==SHARED_LOCK ){
|
||||||
assert( pLock->cnt==0 );
|
assert( pLock->cnt==0 );
|
||||||
assert( id->pOpen->nLock==0 );
|
|
||||||
assert( pLock->locktype==0 );
|
assert( pLock->locktype==0 );
|
||||||
|
|
||||||
/* Grab a read-lock on byte 2. This ensures that no other process
|
/* Grab a read-lock on byte 2. This ensures that no other process
|
||||||
@ -753,7 +750,7 @@ int sqlite3OsLock(OsFile *id, int locktype){
|
|||||||
rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;
|
rc = (errno==EINVAL) ? SQLITE_NOLFS : SQLITE_BUSY;
|
||||||
}else{
|
}else{
|
||||||
id->locked = SHARED_LOCK;
|
id->locked = SHARED_LOCK;
|
||||||
id->pOpen->nLock = 1;
|
id->pOpen->nLock++;
|
||||||
pLock->cnt = 1;
|
pLock->cnt = 1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -782,9 +779,11 @@ int sqlite3OsLock(OsFile *id, int locktype){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
id->locked = locktype;
|
if( rc==SQLITE_OK ){
|
||||||
pLock->locktype = locktype;
|
id->locked = locktype;
|
||||||
assert(pLock->locktype==RESERVED_LOCK||(id->pOpen->nLock==1&&pLock->cnt==1));
|
pLock->locktype = locktype;
|
||||||
|
assert( pLock->locktype==RESERVED_LOCK || pLock->cnt==1 );
|
||||||
|
}
|
||||||
|
|
||||||
end_lock:
|
end_lock:
|
||||||
sqlite3OsLeaveMutex();
|
sqlite3OsLeaveMutex();
|
||||||
@ -800,10 +799,10 @@ end_lock:
|
|||||||
int sqlite3OsUnlock(OsFile *id){
|
int sqlite3OsUnlock(OsFile *id){
|
||||||
int rc;
|
int rc;
|
||||||
if( !id->locked ) return SQLITE_OK;
|
if( !id->locked ) return SQLITE_OK;
|
||||||
|
id->locked = 0;
|
||||||
sqlite3OsEnterMutex();
|
sqlite3OsEnterMutex();
|
||||||
assert( id->pLock->cnt!=0 );
|
assert( id->pLock->cnt!=0 );
|
||||||
if( id->pLock->cnt>1 ){
|
if( id->pLock->cnt>1 ){
|
||||||
id->locked = 0;
|
|
||||||
id->pLock->cnt--;
|
id->pLock->cnt--;
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
}else{
|
}else{
|
||||||
@ -819,9 +818,9 @@ int sqlite3OsUnlock(OsFile *id){
|
|||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
id->pLock->cnt = 0;
|
id->pLock->cnt = 0;
|
||||||
id->pLock->locktype = 0;
|
id->pLock->locktype = 0;
|
||||||
id->locked = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
/* Decrement the count of locks against this same file. When the
|
/* Decrement the count of locks against this same file. When the
|
||||||
** count reaches zero, close any other file descriptors whose close
|
** count reaches zero, close any other file descriptors whose close
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this script is multithreading behavior
|
# focus of this script is multithreading behavior
|
||||||
#
|
#
|
||||||
# $Id: thread1.test,v 1.3 2004/02/11 02:18:07 drh Exp $
|
# $Id: thread1.test,v 1.4 2004/06/02 06:30:18 danielk1977 Exp $
|
||||||
|
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
@ -147,12 +147,12 @@ do_test thread1-2.9 {
|
|||||||
thread_result C
|
thread_result C
|
||||||
} SQLITE_DONE
|
} SQLITE_DONE
|
||||||
do_test thread1-2.10 {
|
do_test thread1-2.10 {
|
||||||
execsql {SELECT * FROM t2}
|
|
||||||
} {98 99}
|
|
||||||
do_test thread1-2.11 {
|
|
||||||
thread_finalize C
|
thread_finalize C
|
||||||
thread_result C
|
thread_result C
|
||||||
} SQLITE_OK
|
} SQLITE_OK
|
||||||
|
do_test thread1-2.11 {
|
||||||
|
execsql {SELECT * FROM t2}
|
||||||
|
} {98 99}
|
||||||
|
|
||||||
thread_halt *
|
thread_halt *
|
||||||
finish_test
|
finish_test
|
||||||
|
Reference in New Issue
Block a user