0

I am using QT5.8 and visual studio 2015 on win10 to control a serial port. The following minimal code crashes in visual studio (but only in debug, release works fine) after the visualization of the messages, so when the object QList infos is destroyed, can anybody explain why?

#include <iostream>
#include <QtSerialPort/QSerialPortInfo>

void showPorts() {
    QList<QSerialPortInfo> infos = QSerialPortInfo::availablePorts();
    for (const QSerialPortInfo &info : infos) {
        std::cout << " detected port : " << info.portName().toStdString() << std::endl;
    }
} // this code CRASHES HERE only in debug ! 


int main (int argc, char** argv){
    std::cout<<"\n >>>  test serial info   <<< \n\n"<<std::endl;

    showPorts();

    std::cout << "\n >>> Finished, press enter to exit  <<< \n\n" << std::endl;
    std::cin.get();

    return 0;
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

1 Answers1

0

I have tested your code and I have not a crash.

PS: Windows 10x64, MSVC2015, Qt 5.8.0 32 bit

Denis Shienkov
  • 517
  • 3
  • 12
  • Thanks for trying, I have win10 and qt 64 bit, MSVC brings to \delete_scalar.cpp and output gives to me : HEAP[test_serialInfo.exe]: Invalid address specified to RtlValidateHeap( 0000025A01D70000, 0000025A01D9D540 ) test_serialInfo.exe has triggered a breakpoint. The program '[8236] test_serialInfo.exe' has exited with code 0 (0x0). – Mauro Bellone May 23 '17 at 17:04
  • Can you please verify that it ends properly? – Mauro Bellone May 23 '17 at 17:29
  • Now, I have checked with Qt 5.8.0 64bit, MSVC2015, Windows10x64, and I have not any crash. – Denis Shienkov May 24 '17 at 08:25
  • Ones more thanks a lot for your help. Does it end properly? Do you visualize the proper outputs? Do you have any serial device connected? I have currently 3 available ports, is it possible that depends on the connected devices ? – Mauro Bellone May 24 '17 at 08:44
  • It ends properly (after tap "enter" button). I see proper outputs. I have three serial devices (COM1 - on-board, COM3-COM4 - virtual com0com). – Denis Shienkov May 24 '17 at 10:06
  • Thank you so much, I still have the error though .... moreover, I have just verified and it happens for 32bit too ... – Mauro Bellone May 24 '17 at 11:52