I have a fairly simple piece of code which launches a QProcess:
launchResultCode = ELaunchOk;
QDateTime beginTimeStamp = QDateTime::currentDateTime();
command->start(commandpath, myParameters);
if (command->waitForStarted(waitToStart)) {
if (!myStdIn.isEmpty()) command->write(myStdIn.toLatin1());
command->closeWriteChannel();
qDebug() << "P1";
if (command->waitForFinished(waitToFinish)) {
myStdOut = command->readAllStandardOutput();
myStdErr = command->readAllStandardError();
} else {
launchResultCode = ELaunchFinishFailed;
}
} else {
launchResultCode = ELaunchStartFailed;
}
qDebug() << "postcorrupt";
And it is causing a corrupted shared library error. When I run this code I get the output from gdb below. I'm trying to figure out what is at either memory location mentioned in the error, but there are no variables there! Can someone help me understand what is going wrong here?
(gdb) c
Continuing.
precorrupt
Detaching after fork from child process 21667.
P1
warning: Corrupted shared library list: 0x7fffe8008970 != 0x7ffff691b000
postcorrupt
[New Thread 0x7fffed453700 (LWP 21668)]
Breakpoint 1, RunProcessWorker::run (this=0x7fffffffcc30, whichMutex=RunProcessWorker::EMutexIP, activityID=..., commandFriendlyName=..., commandpath=...,
enableDebug=true, showDebugCommandLine=true, debugFilenameTemplate=..., myEnvironment=..., myParameters=..., myStdIn=..., myStdOut=..., myStdErr=...,
waitToStart=5000, waitToFinish=5000, actualRunTime=@0x7fffffffca58: 85, launchResultCode=@0x7fffffffca54: RunProcessWorker::ELaunchOk,
qprocessErrorCode=@0x7fffffffca50: QProcess::UnknownError, qprocessesExitCode=@0x7fffffffca6c: 0)
at ../../src/external-sharedfiles/systemcommands/runprocessworker.cpp:292
292 command->deleteLater();
(gdb) info symbol 0x7fffe8008970
No symbol matches 0x7fffe8008970.
(gdb) info symbol 0x7ffff691b000
No symbol matches 0x7ffff691b000.
(gdb)
Note that the error sometimes occurs before my P1 output, so it's something in that area but I can't figure out what! The process forked is a Qt library so I can't see into that library (and probably couldn't understand it)...does this mean it's a bug in Qt library?
Perhaps related, but valgrind shows memory lost on the QProcess start function:
30 (24 direct, 6 indirect) bytes in 1 blocks are definitely lost in loss record 837 of 2,936
in RunProcessWorker::run(RunProcessWorker::EMutex, QString, QString, QString, bool, bool, QString, QStringList, QStringList, QString, QString&, QString&, unsigned int, unsigned int, unsigned long long&, RunProcessWorker::ELaunchResultCodes&, QProcess::ProcessError&, int&) in /mnt/lserver2/data/development/sharedfiles/systemcommands/runprocessworker.cpp:241
1: operator new[](unsigned long) in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
2: /opt/Qt/5.3/gcc_64/lib/libQt5Core.so.5.3.1
3: /opt/Qt/5.3/gcc_64/lib/libQt5Core.so.5.3.1
4: QProcess::start(QString const&, QStringList const&, QFlags<QIODevice::OpenModeFlag>) in /opt/Qt/5.3/gcc_64/lib/libQt5Core.so.5.3.1