Valgrind changes binary behavior

I am trying to track a memory leak in a C ++ program using valgrind. The program is compiled with g ++ and can be run without any errors. Unfortunately, valgrind changes the behavior of my program so that it crashes after you select a runtime error. Since this failure occurs before the relevant parts of the code are reached, I have no way to track a memory leak.

The whole problem is illustrated by the connected console output.

myUser@computer :~$ ./myProgram input.xml Processing... Finished successfully... ---------------------- Hit Enter to continue... myUser@computer :~$ valgrind --leak-check=yes --log-file=valgrindLog ./myProgram input.xml Processing... myProgram-error: Not working Polymorphism. Base class method called instead of derived class method. End-of-myProgram-error. terminate called after throwing an instance of 'char const*' Aborted myUser@computer :~$ g++ -dumpversion 4.4.5 myUser@computer :~$ valgrind --version valgrind-3.6.0.SVN-Debian myUser@computer :~$ uname -r 2.6.35-30-generic myUser@computer :~$ cat /etc/*-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10" 
+4
source share
4 answers

Valgrind probably changes the behavior of your code because you have a bug more serious than a memory leak. The error, portable code, probably will not throw exceptions just because you are running it with valgrind.

+3
source

I had problems in which Valgrind in all cases reveals problems related to conflicts that have never occurred before. I don’t think something like this could be happening here?

0
source

Unfortunately, valgrind changes the behavior of my program so that it crashes after you select a runtime error. Since this failure occurs before the relevant parts of the code are reached, I have no way to track a memory leak.

This is a big luck. Now, in addition to detecting and fixing a memory leak, you can find and fix the error. Have you looked at the main file to find out where your code was damaged?

0
source

Many thanks to all of you !!!

I went back to my code to track the undefined behavior that valgrind detected. Finally, I found it and was able to improve my code.

Thanks again!

0
source

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


All Articles