https://bugs.kde.org/show_bug.cgi?id=377489

            Bug ID: 377489
           Summary: crash in DVcsJob::slotProcessError after QProcess was
                    deleted?!
           Product: kdevplatform
           Version: git master
          Platform: Compiled Sources
                OS: OS X
            Status: UNCONFIRMED
          Severity: crash
          Priority: NOR
         Component: dvcs
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: rjvber...@gmail.com
  Target Milestone: ---

I have been trying to pinpoint the reason for DvcsJob failures to start git
commands on Linux and thus have the following local patches to dvcsjob.c:

```
@@ -193,6 +205,16 @@ void DVcsJob::start()
     d->childproc->start();

     d->model->appendLine(directory().path() + "> " + commandDisplay);
+
+    if (!d->childproc->waitForStarted(100)) {
+        QString error = i18n("DVCSJob::start: %1 failed to start: %2",
commandDisplay, d->childproc->errorString());
+        d->model->appendLine(error);
+        setError( 255 );
+        setErrorText(error);
+        d->status = JobFailed;
+        emitResult();
+        qCWarning(VCS) << error;
+    }
 }

 void DVcsJob::setCommunicationMode(KProcess::OutputChannelMode comm)
@@ -212,9 +234,11 @@ void DVcsJob::slotProcessError( QProcess::ProcessError err
)
     setError(OutputJob::FailedShownError); //we don't want to trigger a
message box

     d->errorOutput = d->childproc->readAllStandardError();
+    QByteArray stdOut = d->childproc->readAllStandardOutput();

     QString displayCommand = KShell::joinArgs(dvcsCommand());
-    QString completeErrorText = i18n("Process '%1' exited with status %2\n%3",
displayCommand, d->childproc->exitCode(),
QString::fromLocal8Bit(d->errorOutput) );
+    QString completeErrorText = i18n("Process '%1' exited with status
%2\n\"%3\"\n\"%4\"",
+        displayCommand, d->childproc->exitCode(),
QString::fromLocal8Bit(stdOut), QString::fromLocal8Bit(d->errorOutput) );
     setErrorText( completeErrorText );

     QString errorValue;
@@ -241,11 +265,11 @@ void DVcsJob::slotProcessError( QProcess::ProcessError
err )
         errorValue = QStringLiteral("UnknownError");
         break;
     }
-    qCDebug(VCS) << "Found an error while running" << displayCommand << ":" <<
errorValue
+    qCWarning(VCS) << "Found an error while running" << displayCommand << ":"
<< errorValue
                                                      << "Exit code is:" <<
d->childproc->exitCode();
-    qCDebug(VCS) << "Error:" << completeErrorText;
-    displayOutput(QString::fromLocal8Bit(d->errorOutput));
-    d->model->appendLine(i18n("Command finished with error %1.", errorValue));
+    qCWarning(VCS) << "Error:" << completeErrorText;
+//     displayOutput(QString::fromLocal8Bit(d->errorOutput));
+    d->model->appendLine(i18n("%1 (%2).", completeErrorText, errorValue));

     if(verbosity()==Silent) {
         setVerbosity(Verbose);
```

Just now I got a weird crash on *Mac* after DvcsJob::start() failed because of
a timeout (the machine was swamped with disk I/O), with this printed on the
terminal:

```
kdevplatform.vcs: "DVCSJob::start: git stash list failed to start: Process
operation timed out"
QProcess: Destroyed while process ("git") is still running.
KCrash: Application 'kdevelop' crashing...
KCrash: Attempting to start /opt/local/libexec/kde5/drkonqi directly
```

I didn't keep the backtrace because initially I wrote this off to overall
instability (a "gremlin"), but then I realised that the crash occurred because
DVcsJob::dvcsCommand() was called from DvcsJob::slotProcessError() *AFTER* the
underlying QProcess had been deleted.

AFAIK that should never happen even in situations like I was seeing; could this
point to a design bug in DVcsJob (or worse, KProcess)?

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to