I am calling a C++
application from the python
script (OS Ubuntu 14.04) like this:
import sys, subprocess
run = subprocess.Popen(['app'] + args, stdout = subprocess.PIPE,
stderr = subprocess.PIPE)
stdout, stderr = run.communicate()
if stderr:
sys.stderr.write('Error in app: ' + stderr.decode('utf-8'))
sys.exit(1)
Then I get the following error message (although the address is different every time):
*** Error in `/usr/bin/app': double free or corruption (!prev): 0x00007f50eae98070 ***
The app itself is a third-party binary, that means, I have no access to the source code. However, even under suggestion that there is some bug in app
that causes deletion attempt the same entity twice there are 3 strangenesses in the behaviour that I cannot understand:
- The error occurs randomly and rather rare (around 20% of all runs on the very same data). Some other users of the
app
get this error as well; however, some of them never get it. - It does not get caught in the
stderr
stream of the subprocess (and thereforesys.exit(1)
does not get executed). - Sometimes I see
top
instead of!prev
in the brackets.
Can someone explain me, how these features can be originated or even give an example C++ code that reproduces this behaviour?