0

I use Sanitizer to compile C code, my compile cmd is:

gcc -fsanitize=address -fsanitize=leak -o test test.c.

When I run ./test in shell, I got the LeakSanitizer Error info.

But When I use subprocess to run ./test in python, I got no stderr and the returncode is 0. My python code:

cmd = './test'
return_info = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
outs, errs = return_info.communicate(timeout=15)
errmsg = errs.decode()
if errmsg == '':
    print('err None')
print(f'return code: {return_info.returncode}')

Is there any way to monitor leaksanitizer's results in python?

icy17
  • 9
  • First establish where the program actually writes in your normal shell with `./test 1> 1.txt 2> 2.txt` so you at least know for sure where to look. Then consider using the simpler `subprocess.run()` per the documentation https://docs.python.org/3/library/subprocess.html – Mark Setchell May 10 '23 at 08:19
  • @MarkSetchell Thanks! After changing docker to VMware, I got the right result. – icy17 Jul 03 '23 at 06:55

0 Answers0