<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Program runs normally but gets Segmentation Fault in debugger]]></title><description><![CDATA[<p dir="auto">I have a simple console app that looks for ports and checks their status for writing.</p>
<pre><code>#include &lt;QCoreApplication&gt;
#include &lt;QSerialPort&gt;
#include &lt;QSerialPortInfo&gt;
#include &lt;QIODevice&gt;
#include &lt;iostream&gt;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QSerialPort port;
    QList&lt;QSerialPortInfo&gt; qports = QSerialPortInfo::availablePorts();

    std::cout &lt;&lt; qports.length() &lt;&lt; " serial ports found\n" &lt;&lt; std::endl;

    for(const QSerialPortInfo &amp;portinfo : qports) {
        std::cout &lt;&lt; "Checking port " &lt;&lt; portinfo.portName().toStdString() &lt;&lt; std::endl;

        port.setPortName(portinfo.portName());


        port.setBaudRate(QSerialPort::Baud9600);
        port.setDataBits(QSerialPort::Data8);
        port.setParity(QSerialPort::NoParity);
        port.setStopBits(QSerialPort::OneStop);
        port.setFlowControl(QSerialPort::HardwareControl);
        bool isOpen = port.open(QIODevice::WriteOnly);
        std::cout &lt;&lt; "Port opened: " &lt;&lt; ((isOpen) ? "TRUE" : "FALSE") &lt;&lt; std::endl;
        std::cout &lt;&lt; "Port writable: " &lt;&lt; ((port.isWritable()) ? "TRUE" : "FALSE") &lt;&lt; std::endl;

        std::cout &lt;&lt; "Port is " &lt;&lt; ((isOpen &amp;&amp; port.isWritable()) ? "" : "not ") &lt;&lt; "ready\n" &lt;&lt; std::endl;

        port.close();
    }
    return a.exec();
}
</code></pre>
<p dir="auto">The program runs successfully on Windows 10 and my output screen looks like this:</p>
<pre><code>3 serial ports found

Checking port COM2
Port opened: FALSE
Port writable: FALSE
Port is not ready

Checking port COM3
Port opened: TRUE
Port writable: TRUE
Port is ready

Checking port COM4
Port opened: FALSE
Port writable: FALSE
Port is not ready
</code></pre>
<p dir="auto">I set a breakpoint and start debugger I enter the debugger and expand the port variable to see its members. Then expanding some of those variables (d and properties) causes a Segmentation Fault dialog window to pop up. After I cancel the dialog I see that the issue occured in qserialport_p.h at the start ofthe  QSerialPortPrivate class definition.</p>
<pre><code>class QSerialPortPrivate : public QIODevicePrivate
{
    Q_DECLARE_PUBLIC(QSerialPort)
</code></pre>
<p dir="auto">I realize that these members have bad addresses. But is this normal or a problem? After I dispose of the dialog the app can continue fine. I want to know if this is a budding problem or if it is just a  quirk of the Debug system. I declare my QSerialPort as a variable rather than construct it since I don't have a parent QObject for it. I want to know if I can ignore this and simply not debug into these QSerialPort members or if this is a future issue.</p>
]]></description><link>https://forum.qt.io/topic/109273/program-runs-normally-but-gets-segmentation-fault-in-debugger</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 04:18:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/109273.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 27 Nov 2019 18:48:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Program runs normally but gets Segmentation Fault in debugger on Thu, 28 Nov 2019 05:41:57 GMT]]></title><description><![CDATA[<p dir="auto">What version of QtCreator? Does creator or the debugger crash?</p>
]]></description><link>https://forum.qt.io/post/564581</link><guid isPermaLink="true">https://forum.qt.io/post/564581</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Thu, 28 Nov 2019 05:41:57 GMT</pubDate></item><item><title><![CDATA[Reply to Program runs normally but gets Segmentation Fault in debugger on Wed, 27 Nov 2019 21:34:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> I am using MinGW 7.3.0 32-bit for C and C++. They are installed at C:\Qt5.12.6\Tools\mingw730_32\bin on my PC. They were installed with Qt Creator and Qt. The debugger is GNU gdb 8.1 for MinGW 7.3.0 32-bit in the same directory.</p>
]]></description><link>https://forum.qt.io/post/564547</link><guid isPermaLink="true">https://forum.qt.io/post/564547</guid><dc:creator><![CDATA[Mike_W]]></dc:creator><pubDate>Wed, 27 Nov 2019 21:34:48 GMT</pubDate></item><item><title><![CDATA[Reply to Program runs normally but gets Segmentation Fault in debugger on Wed, 27 Nov 2019 19:40:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mike_w">@<bdi>Mike_W</bdi></a> said in <a href="/post/564532">Program runs normally but gets Segmentation Fault in debugger</a>:</p>
<blockquote>
<p dir="auto">I cannot expand some of the memebers of the port variable without getting a segmentation fault dialog.</p>
</blockquote>
<p dir="auto">So not your program crashes but the debugger? What compiler and debugger do you use?</p>
]]></description><link>https://forum.qt.io/post/564535</link><guid isPermaLink="true">https://forum.qt.io/post/564535</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 27 Nov 2019 19:40:47 GMT</pubDate></item><item><title><![CDATA[Reply to Program runs normally but gets Segmentation Fault in debugger on Wed, 27 Nov 2019 19:33:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a> The program is compiled in Debug mode and runs fine if I don't try to debug it. However when I set a breakpoint (before executing port.close) and go into the debugger. I cannot expand some of the memebers of the port variable without getting a segmentation fault dialog.</p>
]]></description><link>https://forum.qt.io/post/564532</link><guid isPermaLink="true">https://forum.qt.io/post/564532</guid><dc:creator><![CDATA[Mike_W]]></dc:creator><pubDate>Wed, 27 Nov 2019 19:33:28 GMT</pubDate></item><item><title><![CDATA[Reply to Program runs normally but gets Segmentation Fault in debugger on Wed, 27 Nov 2019 19:10:16 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">but gets Segmentation Fault</p>
</blockquote>
<p dir="auto">So where does it crash?</p>
<blockquote>
<p dir="auto">I  realize that these members have bad addresses.</p>
</blockquote>
<p dir="auto">Qt is compiled in release mode - the debug information can not be accurate then.</p>
]]></description><link>https://forum.qt.io/post/564526</link><guid isPermaLink="true">https://forum.qt.io/post/564526</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 27 Nov 2019 19:10:16 GMT</pubDate></item></channel></rss>