Skip to content

Commit 84e0ad6

Browse files
authored
Fix rare crash in PyNode when a GC collect might be triggered while updating to latest value (#708)
Credit to @aryansoman for tracking down Signed-off-by: Rob Ambalu <robert.ambalu@point72.com>
1 parent 165e1df commit 84e0ad6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

cpp/csp/python/PyNode.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,12 @@ void PyNode::executeImpl()
307307

308308
if( tsinputTicked( idx ) || passiveConvert )
309309
{
310-
Py_XDECREF( *m_localVars[ idx ] );
310+
//Note this is intentionally kept in a temp and decref-ed after updating m_localVars[idx] since
311+
//lastValueToPython can trigger a GC Collect which can reach into generator vars ( localVars ) which would be nulled out
312+
PyObject * old = *m_localVars[ idx ];
311313
*m_localVars[ idx ] = lastValueToPython( ts );
314+
Py_XDECREF( old );
315+
312316
if( passiveConvert )
313317
m_passiveCounts[ idx ] = count;
314318
}

0 commit comments

Comments
 (0)