QVariant and ODBC for iSeries segmentation fault in text field.

Bug #665188 reported by Mondin Marco
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qt4-x11 (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: libqt4-sql-odbc

Ubuntu / Kubuntu 10.04 everything worked perfectly.

With ubuntu / kubuntu 10.10, accessing a database on the IBM iSeries, using a SELECT query from QT4 application, everything works correctly only with numeric fields on the database.
If you try to read a text field with the method "QVariant value (int index) const", it lies in a crash!
The error is as follows:

gconv.c: 75: __gconv: Assertion "outbuf! = ((void *) 0) & & * outbuf! = ((void *) 0) 'failed.
Aborted

It happens on application found on the repositories, just as stacked on personal application.

For example, the application "tora", querying works on numeric fields, but does not work on text fields.

For example, an application personnel arrived at this point in the source:

...
    while(query.next())
    {
      std::cout<<"Valore letto...";
      std::cout.flush();
      num_doc.append(query.value(1).toInt());
      std::cout<<"1...";
      std::cout.flush();
      sleep(3);
      QVariant a=query.value(0);
      std::cout<<"1.5...";
      std::cout.flush();
      main_window->listWidget_cli->addItem(QString("FD nr.")+QString::number(query.value(1).toInt())+QString(" di ")+QString::fromLatin1(query.value(2).toByteArray().data()));
      std::cout<<"2...\n";
      std::cout.flush();
      stato=true;
    }
...

the output is as follows:
...
Valore letto...1...1.5...gfat: gconv.c:75: __gconv: Asserzione "outbuf != ((void *)0) && *outbuf != ((void *)0)" non riuscita.
Aborted

Even with a simple:
...
QVariant a=query.value(2);
...

the output is as follows:
...
gfat: gconv.c:75: __gconv: Asserzione "outbuf != ((void *)0) && *outbuf != ((void *)0)" non riuscita.
Aborted

description: updated
tags: added: database gconv ibm iseries odbc qodbc qstring qt4 qvariant sql
Revision history for this message
Mondin Marco (mondin-marco) wrote :
Download full text (5.6 KiB)

Following is the gdb bugtrace:

#0 0x00007ffff5d0cba5 in raise () from /lib/libc.so.6
#1 0x00007ffff5d106b0 in abort () from /lib/libc.so.6
#2 0x00007ffff5d05a71 in __assert_fail () from /lib/libc.so.6
#3 0x00007ffff5cf93a3 in ?? () from /lib/libc.so.6
#4 0x00007ffff5cf882c in iconv () from /lib/libc.so.6
#5 0x00007fffe3227cb7 in doIconv(void*, unsigned char const*, unsigned char*, unsigned long, unsigned long, unsigned long&, bool) () from /opt/ibm/iSeriesAccess/lib64/libcwbcore.so
#6 0x00007fffe3227de6 in PiNlConverter::convertIconv(unsigned char const*, unsigned char*, unsigned long, unsigned long, PiNlConversionDetail&) const () from /opt/ibm/iSeriesAccess/lib64/libcwbcore.so
#7 0x00007fffe322afd8 in PiNlConverter::convert(unsigned char const*, unsigned char*, unsigned long, unsigned lon
g, PiNlConversionDetail&) const () from /opt/ibm/iSeriesAccess/lib64/libcwbcore.so
#8 0x00007fffe3454236 in STATEMENT_INFO::convertToClientCodePage(char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO const&, unsigned int*, PiNlConverter::PADTYPE, int) ()
   from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#9 0x00007fffe345496b in odbcConv_SQL400_CHAR_to_C_WCHAR(STATEMENT_INFO&, char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO const&, unsigned int*) () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#10 0x00007fffe344e25a in odbcConvSQLtoC(STATEMENT_INFO&, int, int, char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO&, unsigned int*) () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#11 0x00007fffe343d831 in STATEMENT_INFO::odbcGetData(unsigned int, short, char*, int, int*) ()
   from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#12 0x00007fffe344054d in SQLGetData () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#13 0x00007fffe83c97e1 in SQLGetData () from /usr/lib/libodbc.so.1
#14 0x00007fffe861e114 in ?? () from /usr/lib/qt4/plugins/sqldrivers/libqsqlodbc.so
#15 0x00007fffe8628986 in ?? () from /usr/lib/qt4/plugins/sqldrivers/libqsqlodbc.so
#16 0x00007ffff7babc4d in QSqlQuery::value(int) const () from /usr/lib/libQtSql.so.4
#17 0x0000000000422866 in fatture::leggiFatture() ()
#18 0x000000000043d82d in fatture::qt_metacall(QMetaObject::Call, int, void**) ()
#19 0x00007ffff6b98b27 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) ()
   from /usr/lib/libQtCore.so.4
#20 0x00007ffff7468d45 in QDateTimeEdit::dateChanged(QDate const&) () from /usr/lib/libQtGui.so.4
#21 0x00007ffff746f0e1 in ?? () from /usr/lib/libQtGui.so.4
#22 0x00007ffff744929e in ?? () from /usr/lib/libQtGui.so.4
#23 0x00007ffff744c865 in ?? () from /usr/lib/libQtGui.so.4
#24 0x00007ffff744c9ae in QAbstractSpinBox::qt_metacall(QMetaObject::Call, int, void**) ()
   from /usr/lib/libQtGui.so.4
#25 0x00007ffff7470495 in QDateTimeEdit::qt_metacall(QMetaObject::Call, int, void**) ()
   from /usr/lib/libQtGui.so.4
#26 0x00007ffff7470945 in QDateEdit::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libQtGui.so.4
#27 0x00007ffff6b98b27 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) ()
   from /usr/lib/libQtCore.so.4
#28 0x00007ffff749ae72 in QLineEdit::textChanged(QStri...

Read more...

Revision history for this message
Mondin Marco (mondin-marco) wrote :

Here is gdb output:

marco@marco-desktop:~/src/g-suite/gfat$ gdb gfat
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/marco/src/g-suite/gfat/gfat...done.
(gdb) break qsql_odbc.cpp:373
No source file named qsql_odbc.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (qsql_odbc.cpp:373) pending.
(gdb) run
Starting program: /home/marco/src/g-suite/gfat/gfat
[Thread debugging using libthread_db enabled]
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: File o directory non esistente
[New Thread 0x7fffe9007700 (LWP 2281)]
QFileSystemWatcher: failed to add paths: /home/marco/.config/ibus/bus
Bus::open: Can not get ibus-daemon's address.
IBusInputContext::createInputContext: no connection to ibus-daemon
Provo a leggere le fatture...

Preparo la query...

Eseguo la query...

Query eseguita...

Provo a leggere le fatture...

Preparo la query...

Eseguo la query...

Query eseguita...

Provo a leggere le fatture...

Preparo la query...

Eseguo la query...

Query eseguita...

Valore letto...
1...

Breakpoint 1, qGetStringData (hStmt=0xb222c0, column=2, colSize=36, unicode=true)
    at ../../../sql/drivers/odbc/qsql_odbc.cpp:373
373 ../../../sql/drivers/odbc/qsql_odbc.cpp: File o directory non esistente.
        in ../../../sql/drivers/odbc/qsql_odbc.cpp
(gdb) s
379 in ../../../sql/drivers/odbc/qsql_odbc.cpp
(gdb) s
gfat: gconv.c:75: __gconv: asserzione "outbuf != ((void *)0) && *outbuf != ((void *)0)" non riuscita.

Program received signal SIGABRT, Aborted.
0x00007ffff5d0cba5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: File o directory non esistente.
        in ../nptl/sysdeps/unix/sysv/linux/raise.c

Revision history for this message
Mondin Marco (mondin-marco) wrote :
Download full text (9.6 KiB)

Here is gdb bt output:
(gdb) bt
#0 0x00007ffff5d0cba5 in raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff5d106b0 in abort () at abort.c:92
#2 0x00007ffff5d05a71 in __assert_fail (
    assertion=0x7ffff5e22c40 "outbuf != ((void *)0) && *outbuf != ((void *)0)", file=<value optimized out>,
    line=75, function=0x7ffff5e1f7d9 "__gconv") at assert.c:81
#3 0x00007ffff5cf93a3 in __gconv (cd=0x922e80, inbuf=0x7fffffff9bc0,
    inbufend=0xb7ec62 "\362\360\361\360\361\362\363\361\361\360\360\361\367\360\371\302\344\306\306\326@\327\311\305\331\326", '@' <repeats 24 times>"\362, \360\361\360\361\362\363\361\361\360\360\361\367\361\360\326\342\301\303@\342\331\323", '@' <repeats 27 times>"\362, \360\361\360\361\362\363\361\361\360\360\361\367\361\361\302\305\331\343\311\325\326@\301\344\307\344\342\343\326@\242\201\242", '@' <repeats 16 times>"\362, \360\361\360\361\362\363\---Type <return> to continue, or q <return> to quit---
361\361\360\360\361\367\361\362\324\301\343\343\311\326\304\301@\327\311\305\331\311\325\326@P@\306\311\307\323\311@\342\327\301@@@@@@@"..., outbuf=0x7fffffff9bb0, outbufend=0x7ffff7fc9760 "`\227\374\367\377\177",
    irreversible=<value optimized out>) at gconv.c:75
#4 0x00007ffff5cf882c in iconv (cd=0x1210, inbuf=0x7fffffff9bc0, inbytesleft=0x7fffffff9bb8,
    outbuf=0x7fffffff9bb0, outbytesleft=0x7fffffff9ba8) at iconv.c:53
#5 0x00007fffe737631f in doIconv(void*, unsigned char const*, unsigned char*, unsigned long, unsigned long, unsigned long&, bool) () from /usr/lib/libcwbcore.so
#6 0x00007fffe7376456 in PiNlConverter::convertIconv(unsigned char const*, unsigned char*, unsigned long, unsigned long, PiNlConversionDetail&) const () from /usr/lib/libcwbcore.so
#7 0x00007fffe73796a8 in PiNlConverter::convert(unsigned char const*, unsigned char*, unsigned long, unsigned lon---Type <return> to continue, or q <return> to quit---
g, PiNlConversionDetail&) const () from /usr/lib/libcwbcore.so
#8 0x00007fffe75c6f5f in STATEMENT_INFO::convertToClientCodePage(char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO const&, unsigned int*, PiNlConverter::PADTYPE, int) ()
   from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#9 0x00007fffe75c771b in odbcConv_SQL400_CHAR_to_C_WCHAR(STATEMENT_INFO&, char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO const&, unsigned int*) () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#10 0x00007fffe75c2587 in odbcConvSQLtoC(STATEMENT_INFO&, int, int, char const*, char*, unsigned int, unsigned int, COLUMN_INFO&, COLUMN_INFO&, unsigned int*) () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#11 0x00007fffe75b17b9 in STATEMENT_INFO::odbcGetData(unsigned int, short, char*, int, int*) ()
   from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
---Type <return> to continue, or q <return> to quit---
#12 0x00007fffe75b478d in SQLGetData () from /opt/ibm/iSeriesAccess/lib64/libcwbodbc.so
#13 0x00007fffe839d7e1 in SQLGetData () from /usr/lib/libodbc.so.1
#14 0x00007fffe85f2114 in qGetStringData (hStmt=0xb0df00, column=<value optimized out>, colSize=36,
    unicode=<value optimized out>) at ../../../sql/drivers/odbc/qsql_o...

Read more...

Revision history for this message
Mondin Marco (mondin-marco) wrote :

questo bug affligge ubuntu e fedora sia a 32bit che a 64 bit a partire dalle
This bug affects ubuntu and fedora both 32bit and 64bit versions from where unixODBC has taken the place of iODBC. Although the newer versions have libiodbc2, you can not use it because soar QT4 has been compiled with unixODBC.
Since this bug affects different product versions of various distributions, I opened a bug report is also available on Nokia QT.
https://bugreports.qt.nokia.com//browse/QTBUG-23675

Revision history for this message
Mondin Marco (mondin-marco) wrote :

I found the source of the problem and a solution.
In qsql_odbc.cpp file (at line 373 of QT4 version 4.7.4) is the following:

if(unicode) {
r = SQLGetData(hStmt,
column+1,
SQL_C_TCHAR,
NULL,
0,
&lengthIndicator);

The problem is in the NULL pointer.
If the lines are corrected as follows, the problem is resolved:

if(unicode) {
QVarLengthArray<SQLTCHAR> buftmp(colSize);
memset(buftmp.data(), 0, 65536*sizeof(SQLTCHAR));
r = SQLGetData(hStmt,
column+1,
SQL_C_TCHAR,
(SQLPOINTER)buftmp.data(),
0,
&lengthIndicator);

Probably not a very clean solution as I have not had time to analyze in detail the sources, but at least it solves the problem.

Now all QT4 applications that need access to the database on the iSeries with the IBM ODBC driver work properly.

Revision history for this message
Mondin Marco (mondin-marco) wrote :

I made a mistake, the working code is as follows:

if(unicode) {
QVarLengthArray<SQLTCHAR> buftmp(colSize);
memset(buftmp.data(), 0, colSize*sizeof(SQLTCHAR));
r = SQLGetData(hStmt,
column+1,
SQL_C_TCHAR,
(SQLPOINTER)buftmp.data(),
0,
&lengthIndicator);

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.