zend_oo
zend_oo copied to clipboard
Python tests hanging when compiling Zendoo in debug mode
Some Python tests are getting stuck during execution if Zendoo is compiled in debug mode.
Steps to reproduce
CONFIGURE_FLAGS="--enable-debug"
make distclean
./zcutil/build.sh
cd qa/rpc-tests
python prioritisetransaction.py --nocleanup --tracerpc
Analysis
The Python test hangs for a deadlock in Zendoo, the responsible seems to be the call to ShrinkDebugFile()
inside the function LogPrintStr()
(util.cpp
).
The issue shows only in debug mode because the macro DEBUG_LOCKORDER
is activated. Specifically, the deadlock is caused by the fact that some thread performs a LOCK that is detected as a potential deadlock (see the function potential_deadlock_detected()
) and tries to print some debug strings. If this print is the first one requested after the initialization of the debug file, a call to ShrinkDebugFile()
is performed, causing a call to LOCK(csPathCached)
to hang forever since the mutex dd_mutex
is already locked inside the function push_lock
(sync.cpp
).
Possible solutions
- Move the call to
ShrinkDebugFile()
somewhere outsideLogPrintStr()
so that the functionpush_lock()
is never called recursively. - Edit the
push_lock()
function so thatdd_mutex
is reentrant/recursive and does not cause a deadlock anymore (in this case we should carefully analyse the implications of such change).
Additional notes
The issue can be reproduced for any Python test that does not start the Zendoo nodes with the parameter -debug
, since this flag automatically disables the shrink of the debug file.