When Closing MainWindow: The inferior stopped because it received a signal from the operating system
- 
Hello, 
 I am trying to understand what is happening in this application I'm writing.
 Qt 5.15.2, MinGW 32bit under Windows 10 Pro.The problem i'm experiencing is that when pressing the "X" to terminate the application 3 out of 4 times i receive "The inferior stopped because is received a signal from the operating system" 
 Signal Name: ?
 Signal Meaning: Unknown Signal.The debugger shows a window of assembly code, the stack trace shows 
 1 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) [clone .isra.4] 0x68a91120
 2 ??The application: At the moment there is MainWindow, which creates an USBComm object. 
 USBComm is a class i created to wrap libUSB calls. It lives inside the Main Thread, however there is a QFuture object executing a thread to poll for connection/disconnection.
 For now i'm using synchronous calls to read a bulk endpoint (more than enough memory is allocated for the data.).
 This is a class i'm already using in other applications with no problems so i'm not ready to point the finger at it.
 However, i haven't managed to trigger the issue if i haven't connected the USB device (After i connect a device it will exhibit the problem, regardless if the device is connected or not.)I put breakpoints inside the MainWindow destructor, which destroys the USBComm object, then destroys the ui. The error message pops up BEFORE entering the MainWindow destructor so i don't think i'm trying to access unallocated memory, or something like that. 
- 
Hello, 
 I am trying to understand what is happening in this application I'm writing.
 Qt 5.15.2, MinGW 32bit under Windows 10 Pro.The problem i'm experiencing is that when pressing the "X" to terminate the application 3 out of 4 times i receive "The inferior stopped because is received a signal from the operating system" 
 Signal Name: ?
 Signal Meaning: Unknown Signal.The debugger shows a window of assembly code, the stack trace shows 
 1 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) [clone .isra.4] 0x68a91120
 2 ??The application: At the moment there is MainWindow, which creates an USBComm object. 
 USBComm is a class i created to wrap libUSB calls. It lives inside the Main Thread, however there is a QFuture object executing a thread to poll for connection/disconnection.
 For now i'm using synchronous calls to read a bulk endpoint (more than enough memory is allocated for the data.).
 This is a class i'm already using in other applications with no problems so i'm not ready to point the finger at it.
 However, i haven't managed to trigger the issue if i haven't connected the USB device (After i connect a device it will exhibit the problem, regardless if the device is connected or not.)I put breakpoints inside the MainWindow destructor, which destroys the USBComm object, then destroys the ui. The error message pops up BEFORE entering the MainWindow destructor so i don't think i'm trying to access unallocated memory, or something like that. @monegator said in When Closing MainWindow: The inferior stopped because it received a signal from the operating system: however there is a QFuture object executing a thread to poll for connection/disconnection. Then make sure it's done when you close your app. 
- 
@monegator said in When Closing MainWindow: The inferior stopped because it received a signal from the operating system: however there is a QFuture object executing a thread to poll for connection/disconnection. Then make sure it's done when you close your app. @Christian-Ehrlicher said in When Closing MainWindow: The inferior stopped because it received a signal from the operating system: @monegator said in When Closing MainWindow: The inferior stopped because it received a signal from the operating system: however there is a QFuture object executing a thread to poll for connection/disconnection. Then make sure it's done when you close your app. Hi, 
 thanks for answering.
 I have 3 other applications that use the same class and do not exhibit the problem.
 As i said, the error happens before the various destructors are called (and in the destructor for the class that has QFuture the QFuture is told to stop and waits for it to stop)In the meantime I also got this :-1: error: An exception was triggered: 
 Exception at 0x68a91120, code: 0xc0000602: , flags=0x0.Aaaaaaand application output is giving 
 ASSERT: "!x->ref.isStatic()" in file C:\Qt\5.15.2\mingw81_32\include/QtCore/qvector.h, line 714
 Now i think i know where to look (a class i put together in a hurry)And changing the QVector in that class to a QList then goes to 
 ASSERT: "uint(i) < uint(size())" in file C:\Qt\5.15.2\mingw81_32\include/QtCore/qbytearray.h, line 500
- 
I think i found the problem. 
 I use QBytearray to pass the data i receive from USB to the rest of the application.
 In my other applications i directly cast the underlying memory to whatever struct_t is being passed.Instead, in this case, for whatever reason, i converted the data directly uint32_t size; size = data.at(3); size = (size * 256) + data.at(2); size = (size * 256) + data.at(1); size = (size * 256) + data.at(0);which of course should have been uint32_t size; size = (uint8_t)data.at(3); size = (size * 256) + (uint8_t)data.at(2); size = (size * 256) + (uint8_t)data.at(1); size = (size * 256) + (uint8_t)data.at(0);🙄 
 The data being received is a variable length array for which the size is currently capped at 256, and i'm currently requesting it at a high enough rate that less than 128 entries are received, given that the timer that requests the data is still in the GUI thread, whenever i click on the button or move around the window (also would explain while it happened very rarely in that case) the timer event is delayed, but only enough that i receive between 128 and 256 entries... and voilà . getting a signed char from QByteArray, which gets sign extended to 32bit and gets stored as an unsigned 32bit variable.
 
