Re: [sqlite] Bus error on sqlite3_close on Sun Sparc w/SQLite 3.7.4

2011-01-31 Thread Christian Smith
On Wed, Jan 26, 2011 at 02:31:05PM -0500, Joe Mokos wrote:
> I've written an application that uses SQLite 3.7.4.  The application runs
> fine on WinXP, AIX, HPUX and Linux.  When I try to run on Solaris 5.8 SPARC
> I get a bus error when I call sqlite3_close.  I get the following stack
> trace:
> 
>  
> 
> (/opt/SUNWspro/bin/../WS6U2/bin/sparcv9/dbx) where
> 
> current thread: t@1
> 
> =>[1] t_delete(0x1b5ed0, 0xfefbc008, 0x40, 0x1b5e90, 0x1a3840, 0x38), at
> 0xfef427bc
> 
>   [2] realfree(0x1b5ec8, 0xfefc2858, 0xfefbc008, 0x1b5e90, 0x3b, 0x1b5e98),
> at 0xfef423dc
> 
>   [3] _free_unlocked(0xfefc27cc, 0xfefbc008, 0x2a57c8, 0xfefbc008,
> 0xffbede4a, 0x0), at 0xfef42c1c
> 
>   [4] free(0x2a57c8, 0xfefc3a54, 0xfefbfc78, 0xfefbfc78, 0xe9, 0x2a57c8), at
> 0xfef42b6c
> 
>   [5] sqlite3MemFree(0x2a57d0, 0x, 0xc, 0xfef91bf8, 0x1b5d40,
> 0x2a57c8), at 0x5a8cc


Faults from within the libc memory allocator are almost always the result of
heap corruption, typically caused by buffer overruns. Check your code for
potential buffer overruns.

Solaris has good default memory error detection available within libumem. Check
out:
http://developers.sun.com/solaris/articles/libumem_library.html

In combination with mdb, you can find the source of the nmemory allocation
that is corrupted, which may give you a clue about where to look for overruns.

Differences in malloc implementation between different OSes can mask bugs, as 
some
implementations are quite tolerent of subtle bugs like off by one overruns. As
Solaris has a slab based allocator by default, overunning one buffer puts you
straight into the next buffer in the slab, corrupting memory that under Linux
Windows or AIX might be dead space between blocks.

Hope that helps,
Christian
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Bus error on sqlite3_close on Sun Sparc w/SQLite 3.7.4

2011-01-26 Thread Joe Mokos
I've written an application that uses SQLite 3.7.4.  The application runs
fine on WinXP, AIX, HPUX and Linux.  When I try to run on Solaris 5.8 SPARC
I get a bus error when I call sqlite3_close.  I get the following stack
trace:

 

(/opt/SUNWspro/bin/../WS6U2/bin/sparcv9/dbx) where

current thread: t@1

=>[1] t_delete(0x1b5ed0, 0xfefbc008, 0x40, 0x1b5e90, 0x1a3840, 0x38), at
0xfef427bc

  [2] realfree(0x1b5ec8, 0xfefc2858, 0xfefbc008, 0x1b5e90, 0x3b, 0x1b5e98),
at 0xfef423dc

  [3] _free_unlocked(0xfefc27cc, 0xfefbc008, 0x2a57c8, 0xfefbc008,
0xffbede4a, 0x0), at 0xfef42c1c

  [4] free(0x2a57c8, 0xfefc3a54, 0xfefbfc78, 0xfefbfc78, 0xe9, 0x2a57c8), at
0xfef42b6c

  [5] sqlite3MemFree(0x2a57d0, 0x, 0xc, 0xfef91bf8, 0x1b5d40,
0x2a57c8), at 0x5a8cc

  [6] sqlite3_free(0x2a57d0, 0x2a5788, 0xc, 0x0, 0x1, 0x2cda28), at 0x5cad8

  [7] sqlite3DbFree(0x0, 0x2a57d0, 0xc, 0x1b5d08, 0x1c9008, 0x1967a4), at
0x5cbf0

  [8] sqliteDeleteColumnNames(0x0, 0x1b5c28, 0x25, 0x1b5d08, 0x6, 0x1b5aa8),
at 0xb16f8

  [9] sqlite3DeleteTable(0x0, 0x1b5c28, 0x1833d8, 0x0, 0x0, 0x0), at 0xb1884

  [10] sqlite3SchemaFree(0x187b68, 0xfefc0458, 0xff05c000, 0x2, 0x187b68,
0x2c9430), at 0xb9088

  [11] sqlite3ResetInternalSchema(0x187788, 0x0, 0x1ffc, 0x187938, 0x194258,
0x0), at 0xb1470

  [12] sqlite3_close(0x187788, 0x0, 0x0, 0xfef88194, 0x194288, 0x0), at
0xe9070

  [13] SqliteConsumer::disconnect(0x1833a8, 0xfefc0284, 0xfefc3a54,
0xfefbfc78, 0x15f1f6, 0xffbee634), at 0x51f5c

  [14] XML2SQLite::process(0x1833a8, 0x2e, 0x0, 0x0, 0x1, 0x180710), at
0x54298

  [15] MetricUtility::doSqliteConsumerProcess(0x183380, 0x1833a8, 0x185558,
0x0, 0x1, 0x1c), at 0x4e404

  [16] MetricUtility::process(0x183380, 0xffbc, 0xffbee93c, 0x3,
0xff0ea07c, 0x20), at 0x4e2f8

  [17] main(0x7, 0xffbee93c, 0xffbee95c, 0x17e400, 0x0, 0x0), at 0x4e8f0

(/opt/SUNWspro/bin/../WS6U2/bin/sparcv9/dbx) 

 

I know from past experience the bus error usually indicates invalid memory
alignment.  In this case, however, the memory that it is attempting to free
appears to be aligned properly.  The memory is located at 0x002a57c8.  I am
using Sun Workshop 6 to compile both SQLite and my application.  Does anyone
have an idea of what could be causing the bus error?

 

Joe Mokos

 

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users