On Mon, Jun 18, 2007 at 10:26:03PM -0700, Joe Wilson wrote:
> 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 

ftruncate is declared in sys/unistd.h as:

ftruncate(int fd, off_t length)

which is correct.

> 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 

Why would the compiler pass a 64-bit value? off_t is a long (a "c"
long, which is 32-bits under NestedVM, not a java long).

> --- 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);

Ahh... I'd argue this is a clear bug in sqllite. It is assuming off_t
is the same as i64 (which is presumably a typedef to long long).

However, c's implicit narrowing conversions should convert the i64 to
off_t by taking the lower 32-bits, which should still be correct as
long as your offsets fit into 32-bits.

Unless of course you don't have a type declaration for ftruncate in
scope, in which case it will screw up.

-Brian

--~--~---------~--~----~------------~-------~--~----~
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