Important: Please read the Qt Code of Conduct -

QProcess SIGSEGV (0.02 Bitcoin Bounty)

  • I'm offering a 0.02 Bitcoin bounty for whomever can resolve this problem.

    The code below was from a Qt4 project and was working, I've moved it to a Qt5.3 project and it now crashes the client, it is part of a class called MiningPage. The part that causes the crash is in startMining() called when the startButton is pressed. I've tried manually setting the path but it makes no difference.


    The crash is a Segmetation fault.

    Program received signal SIGSEGV, Segmentation fault.
    0x00b14b03 in QNetworkProxy::setApplicationProxy(QNetworkProxy const&) ()

    The args are printed to the GUI by the use of a QListWidget named list, I can only see the arg printed to list if I remove the minerd binary to avoid the crash. toLatin1() was toAscii() in Qt4. Copying and pasting the full command works on the program I'm trying to run if I do it directly.

    void MiningPage::startMining()
        QStringList args;
        QString urlLine = QString("stratum+tcp://");
        QString userpassLine = QString("%1:%2").arg(ui->usernameLine->text(), ui->passwordLine->text());
        args << "--algo" << "scrypt";
        args << "--scantime" << ui->scantimeBox->text().toLatin1();
        args << "--url" << urlLine.toLatin1();
        args << "--userpass" << userpassLine.toLatin1();
        args << "--threads" << ui->threadsBox->text().toLatin1();
        args << "--retries" << "-1"; // Retry forever.
        args << "-P"; // This is needed for this to work correctly on Windows. Extra protocol dump helps flush the buffer quicker.
        // If minerd is in current path, then use that. Otherwise, assume minerd is in the path somewhere.
        QString program = QDir::current().filePath("minerd");
        if (!QFile::exists(program))
            program = "minerd";
        ui->list->addItem(args.join(" ").prepend(" ").prepend(program));

    MiningPage header.

    namespace Ui {
        class MiningPage;
    class ClientModel;
    class MiningPage : public QWidget
        explicit MiningPage(QWidget *parent = 0);
        bool minerActive;
        QProcess *minerProcess;
        QMap<int, double> threadSpeed;
        QTimer *readTimer;
        int initThreads;
        void setModel(ClientModel *model);
    public Q_SLOTS:
        void startPressed();
        void startMining();
        void stopMining();
        void reportToList(QString, int);
        void minerStarted();
        void minerError(QProcess::ProcessError);
        void minerFinished();
        void readProcessOutput();
        void on_startButton_clicked();
    private Q_SLOTS:
        Ui::MiningPage *ui;
        ClientModel *model;
        void resetMiningButton();

    MiningPage constructor.

    MiningPage::MiningPage(QWidget *parent) :
        ui(new Ui::MiningPage)
        minerActive = false;
        minerProcess = new QProcess(this);
        readTimer = new QTimer(this);
        initThreads = 0;
        connect(readTimer, SIGNAL(timeout()), this, SLOT(readProcessOutput()));
        connect(minerProcess, SIGNAL(started()), this, SLOT(minerStarted()));
        connect(minerProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(minerError(QProcess::ProcessError)));
        connect(minerProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(minerFinished()));
        connect(minerProcess, SIGNAL(readyRead()), this, SLOT(readProcessOutput()));

    The mining is started from a button called startButton, the code is simple enough works as we get to the crashing bit of code in startPressed.

    void MiningPage::on_startButton_clicked()

    Full code from the miningpage.cpp

  • Lifetime Qt Champion

    @Bushstar What kind of crash is it? SIGSEGV? Did you try to debug?

  • Added to main question. The crash is SIGSEGV.

    Program received signal SIGSEGV, Segmentation fault.
    0x00b14b03 in QNetworkProxy::setApplicationProxy(QNetworkProxy const&) ()

  • Does this make any sense to get a QNetworkProxy crash here?

    QNetworkProxy is used in the program but is not used in the MiningPage, the program worked as expected until MiningPage was added. Press the button and it never gets past the line.


    I've double check against the previous Qt4 source and it is basically handled in the same way except for the ASCII to Latin1 change.

  • Bumping as I'm adding a 0.02 Bitcoin bounty to anyone who can resolve this issue.

  • Lifetime Qt Champion


    What kind of application is minerd ? Also Qt ?

    Do you get the same crash if you start another application like .e.g ls ?

  • Moderators

    Run it through the debugger and attach a stack trace.

  • @SGaist It is a CLI program and it crashes in the same way if you set it to call ping.

    However commenting out all calls to ClientModel::setMining prevents it from crashing.

    void ClientModel::setMining(bool mining)
        miningStarted = mining;
        Q_EMIT miningChanged(mining);

    The issue is actually assigning miningStarted = mining, I guess that the memory is not allocated for it though it seems to be okay, I hit this sort of issue earlier but did not need the variable so skipped it. This seemed different as I was not getting debug messages from setMining but it is called one time from a connect call based on Started(), I guess that I did not see it so the debug message I was seeing were misleading.

  • Lifetime Qt Champion

    You should first check whether miningStarted is different from the value of mining and only then update its value and emit miningChanged.

    Otherwise, what's connected to that signal ?

Log in to reply