[sqlite] Newbie issue - Linux error malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)

2015-06-06 Thread Dan Kennedy
On 06/06/2015 03:19 AM, George wrote:
> Hello everyone,
>
> I am new to the list. I am working on an application in which I will be
> embedding SQLite as the database engine. The application is written in
> C.
>
> I am currently having an issue which I am not able to resolve at the
> moment so I thought I would ask here since I am just starting out with
> SQLite.
>
> My problem is, from my point of view, that I am not able to perform an
> action to the same database file in the following manner:
>
> 1) I open a database via:
>   sqlite3_initialize()
>   sqlite3_open_v2
> 2) I do some work on getting metadata from the database like table
> names and their fields and then
> 3) I close the connection via:
>   sqlite3_close_v2
>   sqlite3_shutdown
> 4) After all of this is done I wish to process an import file so I need
> to open another connection to the same database file and run some
> statements but when I try to do that I get this on the open call in
> step 1 (above):

I guess that assert() failing means the heap is corrupted. Which might 
be SQLite related or might not.

Running the app under [valgrind] might tell you more. Post its complete 
output here if there are errors but it's not obvious what the problem is.

Dan.




>
> malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)
> &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
> malloc_chunk, fd && old_size == 0) || ((unsigned long) (old_size)
>> = (unsigned long)__builtin_offsetof (struct malloc_chunk,
>> fd_nextsize))+((2 *(sizeof(size_t)) < __alignof__ (long double) ?
>> __alignof__ (long double) : 2 *(sizeof(size_t))) - 1)) & ~((2
>> *(sizeof(size_t)) < __alignof__ (long double) ? __alignof__ (long
>> double) : 2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) &&
>> ((unsigned long) old_end & pagemask) == 0)' failed. Aborted (core
>> dumped)
> This happens in on line 17149 when calling:
>
> p = SQLITE_MALLOC( nByte+8 )
>
> nByte is 64000
>
> in sqlite3.c (amalgamation latest version
> sqlite-amalgamation-3081002.zip)
>
> I am compiling and running the code on:
> Linux x140e 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:28 UTC
> 2015 i686 athlon i686 GNU/Linux
>
> NAME="Ubuntu"
> VERSION="14.04.2 LTS, Trusty Tahr"
> ID=ubuntu
> ID_LIKE=debian
> PRETTY_NAME="Ubuntu 14.04.2 LTS"
> VERSION_ID="14.04"
> HOME_URL="http://www.ubuntu.com/;
> SUPPORT_URL="http://help.ubuntu.com/;
> BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/;
>
> I have compiled sqlite.o with the following:
>
> gcc -c -Wall -O0 -g -std=c99 -Dlinux -I/usr/local/include sqlite3.c \
>  -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION -o obj/sqlite3.o
>
> Any suggestions or directions greatly appreciated.
> TIA,
> George
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] Newbie issue - Linux error malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)

2015-06-06 Thread Simon Slavin

On 5 Jun 2015, at 9:19pm, George  wrote:

> 1) I open a database via:
>   sqlite3_initialize()
>   sqlite3_open_v2
> 2) I do some work on getting metadata from the database like table
> names and their fields and then
> 3) I close the connection via:
>   sqlite3_close_v2
>   sqlite3_shutdown

There's no need to call _initialize().  It won't do any harm, but there's no 
need for it.  The code in _open_v2() checks for it and calls it if you haven't 
already.

If your application is going to do more SQLite, don't call _shutdown().  If you 
have already closed your database connections the amount of resources released 
is negligible and the _shutdown() and _reinitialize() pair can take quite a 
long time to execute.  You can actually forget to call _shutdown() alltogether. 
 All it does is release resources which will be released automatically when 
your program quits.

With all the calls you listed above, are you checking the results returned to 
make sure they're equal to SQLITE_OK ?

If the code in your step (2) includes any statements (e.g. if you use 
_prepare/_step) then are you finalizing each statement before you use _close() 
?  Are you checking the values returned by _finalize() to make sure they're 
SQLITE_OK ?

Simon.


[sqlite] Newbie issue - Linux error malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)

2015-06-06 Thread Keith Medcalf

What embedded OS are you using?  {Perhaps your INIT and SHUTDOWN 
procedures/code is incorrect}. 

If you are not using an embedded OS, why are you calling sqlite3_initialize and 
sqlite3_shutdown?  You do realize that the purpose of sqlite3_shutdown is to 
indicate that you no longer require the use of the sqlite engine in the current 
process because you are, well, finished with it?


> -Original Message-
> From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-
> bounces at mailinglists.sqlite.org] On Behalf Of George
> Sent: Friday, 5 June, 2015 14:19
> To: sqlite-users at mailinglists.sqlite.org
> Subject: [sqlite] Newbie issue - Linux error malloc.c:2372: sysmalloc:
> Assertion `(old_top == (((mbinptr) (((char *)
> 
> Hello everyone,
> 
> I am new to the list. I am working on an application in which I will be
> embedding SQLite as the database engine. The application is written in
> C.
> 
> I am currently having an issue which I am not able to resolve at the
> moment so I thought I would ask here since I am just starting out with
> SQLite.
> 
> My problem is, from my point of view, that I am not able to perform an
> action to the same database file in the following manner:
> 
> 1) I open a database via:
>   sqlite3_initialize()
>   sqlite3_open_v2
> 2) I do some work on getting metadata from the database like table
> names and their fields and then
> 3) I close the connection via:
>   sqlite3_close_v2
>   sqlite3_shutdown
> 4) After all of this is done I wish to process an import file so I need
> to open another connection to the same database file and run some
> statements but when I try to do that I get this on the open call in
> step 1 (above):
> 
> malloc.c:2372: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)
> &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
> malloc_chunk, fd && old_size == 0) || ((unsigned long) (old_size)
> >= (unsigned long)__builtin_offsetof (struct malloc_chunk,
> >fd_nextsize))+((2 *(sizeof(size_t)) < __alignof__ (long double) ?
> >__alignof__ (long double) : 2 *(sizeof(size_t))) - 1)) & ~((2
> >*(sizeof(size_t)) < __alignof__ (long double) ? __alignof__ (long
> >double) : 2 *(sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) &&
> >((unsigned long) old_end & pagemask) == 0)' failed. Aborted (core
> >dumped)
> 
> This happens in on line 17149 when calling:
> 
> p = SQLITE_MALLOC( nByte+8 )
> 
> nByte is 64000
> 
> in sqlite3.c (amalgamation latest version
> sqlite-amalgamation-3081002.zip)
> 
> I am compiling and running the code on:
> Linux x140e 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:28 UTC
> 2015 i686 athlon i686 GNU/Linux
> 
> NAME="Ubuntu"
> VERSION="14.04.2 LTS, Trusty Tahr"
> ID=ubuntu
> ID_LIKE=debian
> PRETTY_NAME="Ubuntu 14.04.2 LTS"
> VERSION_ID="14.04"
> HOME_URL="http://www.ubuntu.com/;
> SUPPORT_URL="http://help.ubuntu.com/;
> BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/;
> 
> I have compiled sqlite.o with the following:
> 
> gcc -c -Wall -O0 -g -std=c99 -Dlinux -I/usr/local/include sqlite3.c \
> -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION -o obj/sqlite3.o
> 
> Any suggestions or directions greatly appreciated.
> TIA,
> George
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users