From 6f79cf1d20452bfd6222410165e13a1b75e1b5bb Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Mon, 4 Sep 2017 14:22:19 +0200 Subject: FIX always remove the callback from the callback itself --HG-- branch : fix-thread-safety --- coverage/ctracer/tracer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'coverage/ctracer') diff --git a/coverage/ctracer/tracer.c b/coverage/ctracer/tracer.c index 236fbbfa..0ade7412 100644 --- a/coverage/ctracer/tracer.c +++ b/coverage/ctracer/tracer.c @@ -1035,7 +1035,10 @@ static PyObject * CTracer_stop(CTracer *self, PyObject *args_unused) { if (self->started) { - PyEval_SetTrace(NULL, NULL); + /* Set the started flag only. The actual call to + PyEval_SetTrace(NULL, NULL) is delegated to the callback + itself to ensure that it called from the right thread. + */ self->started = FALSE; } -- cgit v1.2.1