Finding the cause of a damaged shared library error (Qt5 C ++)

I have a pretty simple piece of code that runs 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 this causes a damaged general library error. When I run this code, I get the output from gdb below. I am trying to figure out what is located anywhere in the memory mentioned in the error, but there are no variables! 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) 

Please note that an error sometimes occurs before my release of P1, so this is something in this area, but I can’t understand that! The forked process is a Qt library, so I cannot see in this library (and probably can not understand it) ... does this mean that this is an error in the Qt library?

Perhaps related, but valgrind shows that memory is lost in the QProcess startup 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&amp;, QString&amp;, unsigned int, unsigned int, unsigned long long&amp;, RunProcessWorker::ELaunchResultCodes&amp;, QProcess::ProcessError&amp;, int&amp;) 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&amp;, QStringList const&amp;, QFlags&lt;QIODevice::OpenModeFlag&gt;) in /opt/Qt/5.3/gcc_64/lib/libQt5Core.so.5.3.1 
0
source share
1 answer

Please note that your error message does not say “corrupted shared library”, but rather “corrupted shared library list”. That is, the list of shared libraries in your process memory space is corrupted, not by the shared libraries themselves. Therefore, my suspicion is not that you have a damaged shared library, but rather that something is rewriting memory in the space of your program memory and causing damage that could damage this list.

It is also interesting that your debugger points to this as a failure site:

 292 command->deleteLater(); 

As you know, deleteLater () is the Qt method for the subsequent removal of QObject (i.e. at the next iteration of the Qt event loop). The most likely cause of program crashes is that the command pointer invoked by this method is invalid (either NULL or dangling). Is the (command) in this case the same QProcess object as the one you call in your code example? If so, is it possible that you already deleted this QProcess object somewhere, leaving the failure code above with a dangling pointer? (If you are not sure, you can subclass QProcess and put the qDebug () statement in the destructor of your subclass so you can see in your output stdout / stderr where and when the QProcess object was destroyed ... and if this debug-print happens before failure, then this is a good clue as to why the failure occurred).

Another possible problem is that you are executing the above code "separately", without a QApplication (or QThread) object executing exec () on the same thread. Since deleteLater () sends a message to the Qt event loop, it will not work properly if there is no Qt event loop and is executed in the same thread.

0
source

Source: https://habr.com/ru/post/1258740/


All Articles