[QtSerialPort] Simple example crashes



  • Hi,

    i'm trying to use the QtSerialPort Libary (http://qt-project.org/wiki/QtSerialPort). The install process worked fine (with Perl installed) and the library files were copied into my Qt installation. (C:\Tools\Qt\Qt5.0.2\5.0.2\mingw47_32 and some other folders).
    The problem is, as soon as i start the simple example of the project wiki (debug or release mode) it crashes with this error:

    Problemsignatur:
    Problemereignisname: APPCRASH
    Anwendungsname: Test.exe
    Anwendungsversion: 0.0.0.0
    Anwendungszeitstempel: 51a3623c
    Fehlermodulname: Qt5Cored.dll
    Fehlermodulversion: 5.0.2.0
    Fehlermodulzeitstempel: 516367ae
    Ausnahmecode: c0000005
    Ausnahmeoffset: 00021f3b
    Betriebsystemversion: 6.1.7601.2.1.0.256.48
    Gebietsschema-ID: 1031
    Zusatzinformation 1: 0a9e
    Zusatzinformation 2: 0a9e372d3b4ad19135b953a78882e789
    Zusatzinformation 3: 0a9e
    Zusatzinformation 4: 0a9e372d3b4ad19135b953a78882e789

    .cpp file:
    @
    #include <QtCore/QCoreApplication>
    #include <QtCore/QDebug>

    #include <QtSerialPort/QSerialPort>
    #include <QtSerialPort/QSerialPortInfo>
     
    QT_USE_NAMESPACE
     
    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
     
    qDebug() << "Begin";
     
    // Example use QSerialPortInfo
    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
    qDebug() << "Name : " << info.portName();
    qDebug() << "Description : " << info.description();
    qDebug() << "Manufacturer: " << info.manufacturer();
     
    // Example use QSerialPort
    QSerialPort serial;
    serial.setPort(info);
    if (serial.open(QIODevice::ReadWrite))
    serial.close();
    }
     
    qDebug() << "End";
    return a.exec&#40;&#41;;
    }
    

    @

    .pro file:
    @
    #-------------------------------------------------
    #
    # Project created by QtCreator 2013-05-10T15:50:24
    #
    #-------------------------------------------------

    QT += core
     
    QT -= gui
     
    QT += serialport
     
    TARGET = Test
    CONFIG += console
    CONFIG -= app_bundle
     
    TEMPLATE = app
     
     
    SOURCES += main.cpp
    

    @

    My setup is:
    Windows 7 Prof. 64 bit
    Qt 5.0.2 32 bit
    QtSerialPort Stable (f301591)

    I already tracked the error with debug mode and there i get a "SIGSEGV" "Segmentation fault" error within the file: "qserialportinfo_win.cpp" in line 132 (QByteArray data(datasize, 0)) while creating a QByteArray for the COM device name (datasize = 10 btw). But i think this can't be the error source, creating a QByteArray within my main.c works perfectly.

    Any further ideas how i can fix this?



  • Hi M4chin3.

    Here at a forum already there was the same problem, but I can't find a this thread. It is strange. Solutions of this problem, certainly still aren't present because the reason is unclear.

    1. Whether your OS has serial ports? Give please a screenshot from Device Manager (with numbers and names of ports).

    2. Can you reproduce a problem without this code?

    @// Example use QSerialPort
    QSerialPort serial;
    serial.setPort(info);
    if (serial.open(QIODevice::ReadWrite))
    serial.close();
    }@

    1. Can you reproduce a problem with Release branch?

    https://qt.gitorious.org/qt/qtserialport/commits/release



  • Hi,

    right now i'm at home. I'll test your recommendations tomorrow.
    Just for the information: I've set up a virtual machine here at home with Qt and QtSerialPort and it works. Same installation process, so this should be fine.

    I will answer to your questions tomorrow.

    Thanks in advance!



  • For me, this problem doesn't repeat, I can't reproduce it. Probably, you incorrectly compiled library.





  • Please try build and install through QtCreator.



  • I just built this with the latest-greatest 5.1 RC1 candidate on Ubuntu 12.04 64 bit. It ran with no problems.



  • @mranger90,

    because this "bug" only for Windows!



  • I got the problem!
    On my linux environment (arch Linux x86_64) it works perfectly (I compiled using qt creator).

    On my windows 7 I was having some troubles to make it works. I was getting the same dll issues that you're having and I solved, that's what I did:

    I reinstalled QT with all the addons (full-installation).
    Removed the Perl that I was using (strawberry Perl)
    Installed Active Perl (the last version)
    Compiled the qtserialport module following this tutorial:
    http://gracianotorrao.com/2013/05/07/how-to-build-the-qserialport-module-using-qt5-windows-7/

    The only exception was that I got the source by cloning the git repository.

    By now it compiles!
    Probably it will work to you too.
    Good luck ^^



  • kuzulis:

    Hi,

    1. I'm trying to use USB-to-Comport devices with a FTDI IC (FT232R). Here's a picture of my device mger:

    "Device manager screen (imgshack)":http://imageshack.us/a/img29/4827/mzma.png

    1. I can reproduce the same error without the lines of code you mentioned. I forgot about this: The error occurs in the head of the foreach loop within the static method "availablePorts()" of class QSerialPortInfo.

    2. I can reproduce the same error with the release branch version of QtSerialPort.

    [quote author="kuzulis" date="1371481349"]Hi M4chin3.

    Here at a forum already there was the same problem, but I can't find a this thread. It is strange. Solutions of this problem, certainly still aren't present because the reason is unclear.

    1. Whether your OS has serial ports? Give please a screenshot from Device Manager (with numbers and names of ports).

    2. Can you reproduce a problem without this code?

    @// Example use QSerialPort
    QSerialPort serial;
    serial.setPort(info);
    if (serial.open(QIODevice::ReadWrite))
    serial.close();
    }@

    1. Can you reproduce a problem with Release branch?

    https://qt.gitorious.org/qt/qtserialport/commits/release[/quote]



  • quickybr:

    I also got strawberry perl, so i tried your way with Active Perl on the WinXp machine.
    -> The QtSerialPort lib was compiled fine (same like with strawberry perl). I also could use it in Qt Creator but it didn't find any of my serial ports. I will check about this in detail tomorrow.

    Why WinXP machine and not the Win7 one iam actually working with?
    -> i dont have admin on the win7 machine. I have to wait for the IT guys untill tomorrow.
    :-/



  • bq. Removed the Perl that I was using (strawberry Perl)
    Installed Active Perl (the last version)

    Hmm.. It is interesting, thx! May it is a cause of problem? Because I'm using Active perl and don't have a problem.

    Can anyone try to check with this difference of Perl?



  • IT department has to check the licences before installtion, so it might take a while. But i'll try as soon as possible.



  • Yesterday I didn't have tried to communicate. But I tested now and I confirm, it's working properly



  • Hi everybody,

    finally i got ActivePerl installed on the Win7 machine. Sadly it didn't change anything for me :-(. I compiled and installed QtSerialPort both ways: via console and via QtCreator and tested it.

    The programm still crashes in the same behaviour as described before.

    This is the crash track in detail:
    main (QSerialPortInfo::availablePorts()) -> qserialportinfo_win.cpp;line 166 (QString s = devicePortName(deviceInfoSet, &deviceInfoData);) -> qserialportinfo_win.cpp;line 132 (QByteArray data(dataSize, 0);)

    The construction of the QByteArray fails somehow and this creates the Qt5Core.dll error. The question is why?



  • Hi,

    okay i' one step further:

    WinXP 32bit:
    Status:
    Couldn't find any serial ports but did not crash like Win7 Pro 64bit. QtSerialPort compiled with Strawberry Perl or ActivePerl didn't matter.

    Problem:
    Administrator priviliges are needed otherwise "::SetupDiEnumDeviceInfo(deviceInfoSet, index++, &deviceInfoData)" returns true but the &deviceInfoData is emtpy respectivly the device name is empty (QString s = devicePortName(deviceInfoSet, &deviceInfoData))

    I'll try to get administrator priviliges tomorrow to try this on Windows7. At least i know how the serial ports are searched on windows systems.

    Will this be changed? Otherwise users of my programm will also need administrator priviliges right? Wouldn't be that good.



  • @M4chin3,

    bq. The question is why?

    I don't know. For a solution I need to reproduce at itself crash - but I can't.

    bq. Otherwise users of my programm will also need administrator priviliges right?

    No. Privileges of the administrator aren't required. Most likely you have any other restrictions on your user account.



  • Hello everyone,

    in the last weeks i had no time for further investigation about the error. Today i opened the example project again, ran it and it works! I Didn't change anything in the code and my priviliges on this machine are the same than i posted the last time.

    I assume that in the time i didn't touch the project the IT department did a windows update via their updatemanagement that fixed my problem. I'll contact them for a list of updates they did in this time. I hope i get a list from them. Maybe i find a patch that could be related to my error.

    I don't have any other explanation for this.



  • Similar issue.

    Using QtSerialPort built from current 'stable' branch (50ab4d) causes simple example (from wiki) to crash in first QSerialPort::open() with segmentation fault (application terminates with exit code 255). Using QtSerialPort built from current 'release' branch (84df6e) works ok.

    My setup is:
    Win7 Pro x64
    Qt 4.8.4



  • Bisecting between revisions I got following results:

    • da0c6b works ok
    • 43f7c6 seems works ok but adds messages to debug output: "virtual void QSerialPort::close(): device not open"
    • 50ab4d causes crash (as described in previous post)

    (Tests was performed by reusing full rebuild cycle: <module build dir> mingw32-make clean, <module build dir> mingw32-make uninstall, clean <module build dir>, clean <app project>, run qmake on <app project>, ...)



  • Hi.

    Yes, I confirm it. Thx.





  • Yes, it fixed issue.
    (But there are still warnings since 43f7c6. Seems like QSerialPort destructor tries to do some finalizing work on already closed port.)



  • (But there are still warnings since 43f7c6. Seems like QSerialPort destructor tries to do some finalizing work on already closed port.)

    It is a not problem.




Log in to reply
 

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