On Wed, Apr 27, 2005 at 04:55:00PM -0500, Jolan Luff wrote: > hi, > > when running the sqlite 3.2.1 regression tests, the lock-2.8 test hangs > indefinitely. if i disable that test, all others pass. > > is this a bug in the regression test or is this something i should be > concerned about? > > thanks, > > - jolan
i searched around on this and saw similar (ignored) reports. there is definitely a bug: #0 0x08a1b915 in nanosleep () from /usr/lib/libc.so.35.1 #1 0x08a61727 in usleep () from /usr/lib/libc.so.35.1 #2 0x1c014349 in sqlite3OsSleep (ms=-32) at src/os_unix.c:1242 #3 0x0aa971c8 in sqliteDefaultBusyCallback (Timeout=0x190, count=0) at src/main.c:640 -32, ouch. the code in question is: static const char delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 50, 100}; static const short int totals[] = { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228, 287}; # define NDELAY (sizeof(delays)/sizeof(delays[0])) ptr timeout = (ptr)Timeout; ptr delay, prior; if( count <= NDELAY ){ delay = delays[count-1]; prior = totals[count-1]; }else{ delay = delays[NDELAY-1]; prior = totals[NDELAY-1] + delay*(count-NDELAY-1); } if( prior + delay > timeout ){ delay = timeout - prior; if( delay<=0 ) return 0; } sqlite3OsSleep(delay); if count is 0: delay = delays[0-1]; this is obviously an invalid array access which is causing the -32. patch follows. - jolan Index: src/main.c =================================================================== RCS file: /sqlite/sqlite/src/main.c,v retrieving revision 1.285 diff -u -r1.285 main.c --- src/main.c 29 Mar 2005 23:34:58 -0000 1.285 +++ src/main.c 28 Apr 2005 08:39:15 -0000 @@ -626,9 +626,9 @@ ptr timeout = (ptr)Timeout; ptr delay, prior; - if( count <= NDELAY ){ - delay = delays[count-1]; - prior = totals[count-1]; + if( count < NDELAY ){ + delay = delays[count]; + prior = totals[count]; }else{ delay = delays[NDELAY-1]; prior = totals[NDELAY-1] + delay*(count-NDELAY-1);