Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:25:36+00:00 2026-06-10T11:25:36+00:00

I’m dealing with what I suspect to be a stack corruption bug in a

  • 0

I’m dealing with what I suspect to be a stack corruption bug in a program that occurs during the use of QNetworkAccessManager. Full source code is available here.

Judging from log output, I’m guessing that the bug is triggered after the asynchronous request on line 44 in calendar.cpp. I don’t have solid evidence of this; I’ve only noticed that the message on line 45 is the last log message most of the time.

Here are lines 39-46:

void Calendar::update()
{
    // Start calendar download asynchronously. After retrieving the
    // file, parseNetworkResponse will take over.
    Logger::instance()->add(CLASSNAME, "Fetching update for 0x" + QString::number((unsigned)this, 16) + "...");
    _naMgr.get(QNetworkRequest(_url));
    Logger::instance()->add(CLASSNAME, "Update request for 0x" + QString::number((unsigned)this, 16) + " was filed.");
}

This HTTP GET request is handled by the Calendar::parseNetworkResponse slot, which is connected to _naMgr‘s finished signal. Here are lines 170-174:

void Calendar::parseNetworkResponse(QNetworkReply* reply) {
    // TODO: we suspect that sometimes a SIGSEGV occurs within the bounds
    // of this function. We'll remove the excessive log calls when we've
    // successfully tracked down the problem.
    Logger::instance()->add(CLASSNAME, "Got update response for 0x" + QString::number((unsigned)this, 16) + ".");

Even when the log message on line 45 isn’t the last to appear in the log after a crash, there is always an update request in the log that is never followed up by the log message at line 174. This leads me to believe that an HTTP GET request might be ruining things here. The URLs for which GET requests are filed appear to be correct.

One of the reasons why I think there’s memory corruption involved is that the bug doesn’t consistently pop up even though the list of input calendars and the status of my internet connection remain the same. (I can trigger the bug with a minimum of 2 calendars.) Furthermore I saw this GCC output when I tried to learn more about the point of failure. I would have collected output from valgrind‘s memory checker to collect additional info but I don’t have a working Linux installation nearby at the moment.

Can this bug be related to incorrect use of Qt’s network libraries from my side? Have you got any other theories as to what might be causing the issue? This is my first time dealing with possible stack corruption and since I’m doing this solo hobby project in my spare time I don’t have anyone to train me in dealing with these issues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:25:38+00:00Added an answer on June 10, 2026 at 11:25 am

    In your finished slot, when you are processing the response set a global flag (bool) to “processing”

    That way, if you get another response, you can either queue it up, or you can ignore it. The problem is probably more due to the fact that QNetworkAccessManager forks a thread to do its processing somewhere behind the scenes, which causes your code to perform access violations.

    If you want I will jump on your project and have a closer look 🙂

    ~ Dan

    My class for sending and receiving:

    .h file

    class sendRec : public QObject
    {
        Q_OBJECT
    public:
        sendRec(QObject *parent = 0);
        sendRec(QUrl);
        QString lastError;
        QUrl thisURL;
        //QNetworkAccessManager manager;
        //FUNCTIONS
        void doGet();
        void doPost(QByteArray*);
        void doPut(QString, QString);
        void doConnects(QNetworkReply *reply, QNetworkAccessManager *manager);
    
    signals:
        void sendResponse(bool, QString*);
    public slots:
    
        /** NETWORK_ACCESS_MANAGER_SLOT **/
        //SUCCESS SLOTS FOR BOTH
        void requestReturned(QNetworkReply * reply );
        //FAILURE SLOTS
        void proxyAuthFail(const QNetworkProxy & proxy, QAuthenticator * authenticator);
        void sslErrorFail(QNetworkReply * reply, const QList<QSslError> & errors);
        /** QNETWORK_REPLY_SLOTS **/
        //FAILURE SLOTS
        void reqError ( QNetworkReply::NetworkError code );
        void sslError ( const QList<QSslError> & errors );
    
    };
    

    .cpp:

    #include "sendrec.h"
    
    sendRec::sendRec(QObject *parent) :
        QObject(parent)
    {
    }
    
    
    sendRec::sendRec(QUrl url) {
        thisURL = url;
    }
    
    void sendRec::doGet() {
        QNetworkRequest request(thisURL);
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        QNetworkReply *reply = manager->get(request);
        doConnects(reply, manager);
    }
    
    void sendRec::doPost(QByteArray *message) {
        QNetworkRequest request(thisURL);
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        QNetworkReply *reply = manager->post(request, *message);
        doConnects(reply, manager);
    }
    
    void sendRec::doConnects(QNetworkReply *reply, QNetworkAccessManager* manager){
        //Reply Connects
        QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
                         this, SLOT(reqError(QNetworkReply::NetworkError)));
        QObject::connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
                         this, SLOT(sslError(QList<QSslError>)));
        //manager connects
        QObject::connect(manager, SIGNAL(finished(QNetworkReply*)),
                   this, SLOT(requestReturned(QNetworkReply*)));
        QObject::connect(manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
                this, SLOT(sslErrorFail(QNetworkReply*,QList<QSslError>)));
        QObject::connect(manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
                   this, SLOT(proxyAuthFail(QNetworkProxy,QAuthenticator*)));
    
    
    }
    
    
    void sendRec::requestReturned(QNetworkReply * rep ){
        qDebug() << "Request Returned";
        QVariant status = rep->attribute(QNetworkRequest::HttpStatusCodeAttribute);
        if(status != 200 || status == NULL) {
            QString *lastError = new QString("ERROR: " + status.toString()
                                             + " " + rep->readAll());
            emit sendResponse(false, lastError);
        } else {
            QString *retString = new QString(rep->readAll());
            *retString = retString->trimmed();
            emit sendResponse(true, retString);
        }
        rep->manager()->deleteResource(rep->request());
        rep->manager()->deleteLater();
        rep->deleteLater();
        sender()->deleteLater();
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.