Package: libsqliteodbc
Version: 0.992-2
Severity: grave

Hello,

sqlite3+odbc segfaults with this simple test case, which as far as I
understand ODBC is just a standard connect and prepare sequence.

The segfault happens in the current Jessie and in Fedora 20.

$ cat sqlite-odbc.c
#include <sql.h>
#include <sqlext.h>
#include <assert.h>
#include <stdlib.h>

int main()
{
    // Allocate ODBC environment handle and register version
    SQLHENV od_env;
    assert(SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &od_env) == 
SQL_SUCCESS);
    assert(SQLSetEnvAttr(od_env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0) 
== SQL_SUCCESS);

    SQLHDBC od_conn;
    assert(SQLAllocHandle(SQL_HANDLE_DBC, od_env, &od_conn) == SQL_SUCCESS);

    // Connect to the DSN
    char sdcout[1024];
    SQLSMALLINT outlen;
    assert(SQLDriverConnect(od_conn, NULL,
                    (SQLCHAR*)"Driver=SQLite3;Database=test.sqlite;", SQL_NTS,
                    (SQLCHAR*)sdcout, 1024, &outlen,
                    SQL_DRIVER_NOPROMPT) == SQL_SUCCESS);

    // Create a statement
    SQLHSTMT stm;
    assert(SQLAllocHandle(SQL_HANDLE_STMT, od_conn, &stm) == SQL_SUCCESS);


    // Prepare a query
    assert(SQLPrepare(stm, (SQLCHAR*)"SELECT COUNT(*) FROM sqlite_master WHERE 
type='table' AND name=?", SQL_NTS) == SQL_SUCCESS);


    // All good, deallocate things
    SQLFreeHandle(SQL_HANDLE_STMT, stm);
    SQLFreeHandle(SQL_HANDLE_DBC, od_conn);
    SQLFreeHandle(SQL_HANDLE_ENV, od_env);
}
$ gcc -g sqlite-odbc.c -o sqlite-odbc -lodbc
$ rm -f test.sqlite  # Not needed, but it keeps the tests stateless
$ ./sqlite-odbc
Segmentation fault
$ rm -f test.sqlite  # Not needed, but it keeps the tests stateless
$ gdb ./sqlite-odbc
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
[...]
(gdb) run
Starting program: /home/enrico/lavori/arpa/dballe/sqlite-odbc
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6abc537 in sqlite3_stricmp () from 
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0
(gdb) where
#0  0x00007ffff6abc537 in sqlite3_stricmp () from 
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#1  0x00007ffff6abd485 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#2  0x00007ffff6abecf6 in ?? () from /usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#3  0x00007ffff6b29188 in sqlite3_table_column_metadata () from 
/usr/lib/x86_64-linux-gnu/libsqlite3.so.0
#4  0x00007ffff6d8180d in ?? () from 
/usr/lib/x86_64-linux-gnu/odbc/libsqlite3odbc.so
#5  0x00007ffff6d882d0 in ?? () from 
/usr/lib/x86_64-linux-gnu/odbc/libsqlite3odbc.so
#6  0x00007ffff6d88965 in ?? () from 
/usr/lib/x86_64-linux-gnu/odbc/libsqlite3odbc.so
#7  0x00007ffff7b94481 in SQLPrepare () from 
/usr/lib/x86_64-linux-gnu/libodbc.so.2
#8  0x0000000000400957 in main () at sqlite-odbc.c:30
(gdb)


Regards,

Enrico

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libsqliteodbc depends on:
ii  libc6              2.19-13
ii  libsqlite0         2.8.17-12
ii  libsqlite3-0       3.8.7.1-1
ii  multiarch-support  2.19-13

libsqliteodbc recommends no packages.

Versions of packages libsqliteodbc suggests:
ii  unixodbc-bin  2.3.0-4

-- no debconf information


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to