|Hi I am using Qt to connect to a Sqlite3 database (3.6.23-1). Source is just included with my app, not a dll / lib. System: Mac OSX 10.6 and Ubuntu 9.10 (GCC 4.4) The method of getting a sqlite* is described in the Qt docs and I have checked the memory addresses in gdb and the returned sqlite3* really is valid. sqlite.magic also = OPEN. Other ref: |http://www.mail-archive.com/sqlite-users@sqlite.org/msg25807.html | The issues is I get a SIGSEGV on the sqlite_exec call
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("test.db"); if ( db.open() ) { // If uncommented this works fine //db.exec("CREATE TABLE normalMethod1 ( id INT(64), value CHAR(32) )"); // This is taken from the Qt Docs QVariant v = db.driver()->handle(); if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) { // v.data() returns a pointer to the handle sqlite3 *handle = *static_cast<sqlite3 **>(v.data()); if (handle != 0) { // check that it is not NULL qint64 id = sqlite3_last_insert_rowid((sqlite3 *)handle); // <-- This works fine char* localError=0; const char* sql = "CREATE TABLE tblOne (id int(32), name char(16))"; int rc = sqlite3_exec(handle, sql, 0, 0, &localError); // <-- This causes SIGSEGV if (rc != SQLITE_OK) { qFatal("Sqlite3 failed with %i", rc); } } } } | The gdb output and stack backtrace is: Core was generated by `./pcs_debug'. Program terminated with signal 11, Segmentation fault. [New process 31016] [New process 31017] #0 0x00000000 in ?? () (gdb) run ./pcs_debug Starting program: /...../pcs_debug ./pcs_debug [Thread debugging using libthread_db enabled] [New Thread 0xb7749970 (LWP 31147)] Xlib: extension "RANDR" missing on display ":0.0". ** (<unknown>:31147): CRITICAL **: atk_object_set_name: assertion `name != NULL' failed [New Thread 0xb7516b70 (LWP 31152)] [Thread 0xb7516b70 (LWP 31152) exited] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7749970 (LWP 31147)] 0x00000000 in ?? () (gdb) backtrace #0 0x00000000 in ?? () #1 0x08058f8e in sqlite3_mutex_enter (p=0x90d98c0) at 3rdparty/sqlite3/sqlite3.c:14549 #2 0x080bc6d5 in sqlite3_exec (db=0x90d3ab0, zSql=0x80f4f34 "CREATE TABLE tblOne (id int(32), name char(16))", xCallback=0, pArg=0x0, pzErrMsg=0xbfda0388) at 3rdparty/sqlite3/sqlite3.c:76821 #3 0x0804f732 in main (argc=2, argv=0xbfda04b4) at src/main.cpp:58 I have to say that I'm stuck and think this is an issue with threading in sqlite3. Thanks Neville _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users