On 10/28/2016 05:39 PM, [email protected] wrote:
Hi Rowan,

On Fri Oct 28, 2016 at 06:19:59PM +0800, Rowan Worth wrote:
Every sqlite_stmt you use *must* be finalized via sqlite3_finalize.
I'm not exactly sure what that looks like from the other side of DBD,
but I would be checking your perl code for a statement/resultset
object which outlives the database connection itself.
Some of my new debug statements appear to confirm that: database
handles are being cleaned up before statement handles, even though
presumably the statement handle still has a reference back to the
database.

SQLite should handle that. If you call sqlite3_close() before all statement handles have been cleaned up, the call fails with SQLITE_MISUSE. Or if you use sqlite3_close_v2(), the call succeeds, but a reference count is used to ensure that the db handle object is not actually deleted until all statements are. close_v2() was added for this situation - where a garbage collectors or similar is responsible for closing db handles and finalizing statements.

This looks like the statement handle being passed to sqlite3_finalize() has already been finalized. Or perhaps that it is just a stray pointer that was never a statement handle. To confirm, jump back to the sqlite3VdbeFinalize() frame of your stacktrace and do "print *p". The entire object has likely been 0xdf'd out.

If this is repeatable, try running it under valgrind. The valgrind error should make it pretty clear whether or not the statement handle really has already been finalized.

Dan.





So I also did some googling on that topic, and it appears that during
Perl's global destruction phase objects may not necessarily be
destroyed in the right order.  That is something I unfortunately don't
have any easy control over :-( Perhaps I can be more explicit
somewhere...

In any event this is probably not an sqlite issue.

Thanks for commenting.

Mark.


_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to