On Sat, 06 Jun 2015 21:14:46 +0700
Dan Kennedy <danielk1977 at gmail.com> wrote:

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

Thanks to everyone who answered!

I am doing this on Linux not on an embedded system, Ubuntu 14.04 LTS to
be more precise.

I removed the initialize and shutdown which I had wrapped into my
connect and close methods after reading the "Using SQLite" book and
probably misunderstanding it...

The problem is still there even after I removed the 2 function calls.

I ran the whole app under the valgrind memory checker and it and
valgrind crashed at the end when the explosion happens. Here is the
summary:

==6013== HEAP SUMMARY:
==6013==     in use at exit: 0 bytes in 0 blocks
==6013==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==6013== 
==6013== All heap blocks were freed -- no leaks are possible
==6013== 
==6013== For counts of detected and suppressed errors, rerun with: -v
==6013== Use --track-origins=yes to see where uninitialised values come
from ==6013== ERROR SUMMARY: 2113 errors from 137 contexts (suppressed:
0 from 0)
Aborted (core dumped)
make: *** [vg-check-import] Error 134

I do check the return codes and print any errors with sqlite3_errmsg to
see if I can move into another direction.

I also checked my code and I do finalize my statement before the close.

It seems that when I go second time around things go bad...

Not sure what is going on here...
Looking ...
Thanks guys,
George


> 
> 
> 
> 
> >
> > 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-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to