QSqlDatabase::open() chrashes application on target system.



  • Hello,
    I currently try to deploy my Qt 5.2.1 application on my embedded i686 target System.
    I'm shipping all required libs from my development system which is also an i686 architecture.

    The application is an cli tool without graphical interface.
    It runs fine up to the point where I have to initialize the database connection.
    I really need some help here because I run out of Ideas what might be wrong with my deployment.
    @

    QString driver = this->core->getSettingsHandlder()->getSettingByKey("db-driver");
    qDebug() << "init database connection with driver: " << driver;
    this->database = QSqlDatabase::addDatabase(driver);
    
    QString dbhost = this->core->getSettingsHandlder()->getSettingByKey("db-host");
    QString dbname = this->core->getSettingsHandlder()->getSettingByKey("db-name");
    QString dbpass = this->core->getSettingsHandlder()->getSettingByKey("db-password");
    QString dbuser = this->core->getSettingsHandlder()->getSettingByKey("db-user");
    
    qDebug() << this->database.drivers();
    qDebug() << this->database.driverName();
    qDebug() << "setting database param";
    this->database.setHostName(dbhost);
    this->database.setDatabaseName(dbname);
    this->database.setUserName(dbuser);
    this->database.setPassword(dbpass);
    
    qDebug() << "try to open database";
    try {
        if (!this->database.open())
        {
            throw eDatabaseException(this->database.lastError().text());
        }
    } catch (...) {
        throw eDatabaseException("error on opening Database");
    }
    
    qDebug() << "Database is open";
    

    @

    This is the log i get from this code:
    @
    init database connection with driver: "QOCI"
    ("QOCI", "QOCI8") //this->database.drivers()
    "QOCI" //this->database.driverName();
    setting database param
    try to open database
    @

    And thats it. After a delay of a few seconds the application crashes and I'm back at the prompt.
    I get no error from the QSqlDatabase object and even the the catch block fails.

    What do i have to do to get the database driver to run correctly ?
    What might cause this crash ?

    I started deploying my development driver from my host.
    Now I compiled the driver on the target system itself and it keeps crashing.

    I installed the oracle-instantclient packages
    All dependencies seem to be available:
    @
    ldd /opt/controller/plugins/sqldrivers/libqsqloci.so
    linux-gate.so.1 => (0xb77de000)
    libclntsh.so.11.1 => /usr/lib/oracle/11.2/client/lib/libclntsh.so.11.1 (0xb5ab9000)
    libQt5Sql.so.5 => /opt/Qt/5.2.1/gcc/lib/libQt5Sql.so.5 (0xb5a7a000)
    libQt5Core.so.5 => /opt/Qt/5.2.1/gcc/lib/libQt5Core.so.5 (0xb55b0000)
    libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xb5590000)
    libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb54a4000)
    libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xb547e000)
    libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb5461000)
    libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb52fc000)
    libnnz11.so => /usr/lib/oracle/11.2/client/lib/libnnz11.so (0xb50af000)
    libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xb50ab000)
    libnsl.so.1 => /lib/i386-linux-gnu/i686/cmov/libnsl.so.1 (0xb5094000)
    libaio.so.1 => /lib/i386-linux-gnu/libaio.so.1 (0xb5091000)
    libicui18n.so.51 => /opt/LiteRechner/libicui18n.so.51 (0xb4e6e000)
    libicuuc.so.51 => /opt/LiteRechner/libicuuc.so.51 (0xb4cf5000)
    libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0xb4cf2000)
    librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xb4ce9000)
    libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb4bec000)
    /lib/ld-linux.so.2 (0xb77df000)
    libicudata.so.51 => /opt/LiteRechner/libicudata.so.51 (0xb36a2000)
    libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb3664000)
    @

    Thank you guys



  • Hi, if you give it wrong hostname, or wrong username/password does it still crash?
    Also, to get more information, in Linux you can start a program with strace, it will log all system calls etc.



  • Thanks mate i will try to use strace to narrow the problem down.
    And no the application doesn't crash if the connection parameter are wrong.
    in that case I got an error.

    I'm currently try to deploy to an Ubuntu 14.04 os which comes with Qt 5.2.1.
    A first test deploy seem to work just fine.
    Maybe there are some issues with the libraries.



  • I'm still struggeling to get the driver to work.
    I was able to reconstruct the error on one of my development machines.

    I set the LD_LIBRARY_PATH=/opt/Qt/5.2.1/gcc/lib/:/usr/lib/oracle/11.2/client/lib/
    to ensure that the application finds the libclntsh.so.11.1 lib.

    This seem to cause the crash if I remove the :/usr/lib/oracle/11.2/client/lib/ path it works. but this seem to work only because there is another libclntsh.so.11.1 in /lib/i386-linux-gnu/
    which i don't have on my other systems.

    How am I supposed to deploy an Qt application that uses the sql driver plugins ?



  • Here is the last part of the trace of the application.

    @
    rt_sigaction(SIGBUS, {0xb497d354, [], SA_SIGINFO}, NULL, 8) = 0
    rt_sigaction(SIGSEGV, {0xb497d354, [], SA_SIGINFO}, NULL, 8) = 0
    rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
    write(9, "<-B71F1450", 10) = 10
    rt_sigprocmask(SIG_SETMASK, ~[BUS SEGV RTMIN RT_1], [], 8) = 0
    rt_sigaction(SIGBUS, NULL, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGBUS, {0xb4972664, [ALRM], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
    rt_sigaction(SIGSEGV, NULL, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGSEGV, {0xb4972664, [ALRM], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
    rt_sigprocmask(SIG_BLOCK, NULL, ~[BUS KILL SEGV STOP RTMIN RT_1], 8) = 0
    --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1a1} ---
    rt_sigprocmask(SIG_SETMASK, ~[BUS KILL SEGV STOP RTMIN RT_1], NULL, 8) = 0
    rt_sigaction(SIGBUS, {0xb497d354, [], SA_SIGINFO}, NULL, 8) = 0
    rt_sigaction(SIGSEGV, {0xb497d354, [], SA_SIGINFO}, NULL, 8) = 0
    rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
    write(9, "<-000001A1", 10) = 10
    munmap(0xb2d67000, 45056) = 0
    munmap(0xb77d0000, 8192) = 0
    close(13) = 0
    munmap(0xb77d2000, 28672) = 0
    close(12) = 0
    munmap(0xb2d72000, 2662400) = 0
    close(11) = 0
    gettimeofday({1400230835, 238411}, NULL) = 0
    _llseek(9, 0, [798], SEEK_CUR) = 0
    write(10, "MI00G$03e40\n", 12) = 12
    _llseek(9, 0, [798], SEEK_CUR) = 0
    write(9, "----- START Event Driven Actions"..., 43) = 43
    write(10, "EG006$Event Triggered Actions1V"..., 34) = 34
    _llseek(9, 0, [841], SEEK_CUR) = 0
    write(9, "---- END Event Driven Actions Du"..., 40) = 40
    write(10, "UG$06e\n", 7) = 7
    _llseek(9, 0, [881], SEEK_CUR) = 0
    write(9, "----- START DDE Actions Dump ---"..., 35) = 35
    write(10, "AGs1M$dbgerRunActions
    dbger.cDD"..., 47) = 47
    gettimeofday({1400230835, 239865}, NULL) = 0
    _llseek(9, 0, [916], SEEK_CUR) = 0
    write(9, "Executing SYNC actions\n", 23) = 23
    write(10, "C4$RNdEb2"\n", 11) = 11
    _llseek(9, 0, [939], SEEK_CUR) = 0
    write(9, "Executing ASYNC actions\n", 24) = 24
    write(10, "C{0O\n", 5) = 5
    _llseek(9, 0, [963], SEEK_CUR) = 0
    write(9, "----- END DDE Actions Dump (tota"..., 48) = 48
    write(10, "QH00G$Z1act_exec_duration`1Y:0tM"..., 34) = 34
    lstat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=280, ...}) = 0
    stat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=280, ...}) = 0
    open("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", O_WRONLY|O_APPEND|O_LARGEFILE) = 11
    fcntl64(11, F_SETFD, FD_CLOEXEC) = 0
    lstat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=280, ...}) = 0
    stat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=280, ...}) = 0
    open("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", O_RDONLY|O_LARGEFILE) = 12
    fcntl64(12, F_SETFD, FD_CLOEXEC) = 0
    stat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=280, ...}) = 0
    _llseek(12, 0, [0], SEEK_SET) = 0
    read(12, "<?xml version="1.0" encoding="US"..., 1024) = 280
    close(12) = 0
    write(11, "</", 2) = 2
    write(11, "Incident_2", 10) = 10
    write(11, ">", 1) = 1
    write(11, "\n", 1) = 1
    write(11, "</", 2) = 2
    write(11, "Staging_Document", 16) = 16
    write(11, ">", 1) = 1
    write(11, "\n", 1) = 1
    close(11) = 0
    stat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", {st_mode=S_IFREG|0640, st_size=314, ...}) = 0
    stat64("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stg1_41_inc2.swp", 0xbfe39314) = -1 ENOENT (No such file or directory)
    rename("/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stgx_41_inc2.swp", "/root/oradiag_root/diag/clients/user_root/host_3348935839_80/sweep/stg1_41_inc2.swp") = 0
    _llseek(9, 0, [1011], SEEK_CUR) = 0
    write(9, "End of Incident Dump\n", 21) = 21
    write(10, "U0q41$dbgexEndIncident
    4SL\n", 27) = 27
    close(9) = 0
    close(10) = 0
    rt_sigaction(SIGQUIT, NULL, NULL, 8) = 0

    .
    .
    .

    rt_sigaction(SIGTRAP, {SIG_DFL, [], 0}, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGXCPU, NULL, NULL, 8) = 0
    rt_sigaction(SIGXCPU, NULL, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGXCPU, {SIG_DFL, [], 0}, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGXFSZ, NULL, NULL, 8) = 0
    rt_sigaction(SIGXFSZ, NULL, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    rt_sigaction(SIGXFSZ, {SIG_DFL, [], 0}, {0xb497d354, [], SA_SIGINFO}, 8) = 0
    tgkill(26098, 26098, SIGSEGV) = 0
    --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_TKILL, si_pid=26098, si_uid=0} ---
    +++ killed by SIGSEGV (core dumped) +++
    Speicherzugriffsfehler (Speicherabzug geschrieben)
    @

    The "Speicherzugriffsfehler" is the memory access error.



  • Hi, it seems you indeed have a "DLL hell" with that Oracle .so file. (I had a similar problem when connecting to MS SQLServer from Ubuntu 14.04 and there were different libiodbc.so's, and only one worked.)

    Instead of changing LB_LIBRARY_PATH you can try changing the rpath in libqsqloci.so to $ORIGIN with the chrpath utlity and then copy the working libclntsh.so.11.1 so it's together with your main .elf file. That way your app should hopefully load the correct libclntsh.so.11.1.

    You can read more about using chrpath in my "blog post":http://www.tripleboot.org/?p=138 scroll down to "Linux GCC..."


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.