[3/5] server/process: Disable gc around critical section

Message ID 20220403102144.1679700-3-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 96a6303949cefd469bcf5ed250ff512271354357
Headers show
Series [1/5] parse: Ensure any existing siggen is closed down first | expand

Commit Message

Richard Purdie April 3, 2022, 10:21 a.m. UTC
The python gc can trigger whilst we're holding the event stream lock
and when cleaning up objects, they can trigger warnings. This translates
into a new event which would then need the lock and we can deadlock.

Disable gc whilst we hold that lock to avoid this unfortunate and
problematic situation.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/server/process.py | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index ce53fdc678..19ef83980f 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -28,6 +28,7 @@  import re
 import datetime
 import pickle
 import traceback
+import gc
 import bb.server.xmlrpcserver
 from bb import daemonize
 from multiprocessing import queues
@@ -739,8 +740,10 @@  class ConnectionWriter(object):
         self.event = self
 
     def _send(self, obj):
+        gc.disable()
         with self.wlock:
             self.writer.send_bytes(obj)
+        gc.enable()
 
     def send(self, obj):
         obj = multiprocessing.reduction.ForkingPickler.dumps(obj)