This sqlite database corruption bug under NestedVM is pure 
concentrated evil.

It is sort-of a NestedVM bug in the sense that it did not have 
a proper declaration of ftruncate(int fd, off_t length) which 
ultimately causes the mips cross-compiler to push a 64 bit value 
for the off_t parameter instead of the 32 bit value NestedVM/mips 
was expecting. This resulted in a psuedo-random stack value for 
ftruncate length being used by NestedVM. Strangely, although this 
value was completely wrong much of the time, most sqlite operations 
still worked.

Although NestedVM could include a patch to fix its newlib header 
file, this bug can also be fixed in SQLite source code with the patch
below.

A NestedVM compiled version of the sqlite-3.4.0 commandline shell
with the fix can be found here: http://sqlite.org/contrib?orderby=date
It passes the test at the bottom of this email.

Original bug report:
http://groups.google.com/group/sqlitejdbc/browse_thread/thread/a1535f3419c07796


Index: src/os_unix.c
===================================================================
RCS file: /sqlite/sqlite/src/os_unix.c,v
retrieving revision 1.133
diff -u -3 -p -r1.133 os_unix.c
--- src/os_unix.c       8 Jun 2007 18:27:03 -0000       1.133
+++ src/os_unix.c       19 Jun 2007 05:04:52 -0000
@@ -1271,7 +1271,7 @@ int sqlite3UnixSyncDirectory(const char 
 static int unixTruncate(OsFile *id, i64 nByte){
   int rc;
   assert( id );
-  rc = ftruncate(((unixFile*)id)->h, nByte);
+  rc = ftruncate(((unixFile*)id)->h, (off_t)nByte);
   SimulateIOError( rc=1 );
   if( rc ){
     return SQLITE_IOERR_TRUNCATE;

--- Joe Wilson <[EMAIL PROTECTED]> wrote:
> If you pipe the output of this perl script containing a reduced test
> case to a NestedVM-compiled sqlite3 commandline shell you can reproduce 
> the problem - but only if you're using a file-based database. 
> If you're using a :memory: database, then this problem will not occur. 
> This suggests that the problem is in a NestedVM I/O system call, as
> a natively compiled version of sqlite3 works correctly with the same SQL.
> 
> #!perl
> my $data = "D" x 8126;
> print "
> PRAGMA page_size=1024;
> PRAGMA cache_size=10;
> CREATE TABLE messages (id INTEGER PRIMARY KEY AUTOINCREMENT, data);
> BEGIN;
> INSERT INTO messages (data) VALUES ('$data');
> COMMIT;
> DELETE FROM messages WHERE id != 1234567;
> VACUUM;
> VACUUM;
> ";



 
____________________________________________________________________________________
Get your own web address.  
Have a HUGE year through Yahoo! Small Business.
http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLiteJDBC" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlitejdbc?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to