GC thread safe?

Tim Peters tim.one at comcast.net
Thu Mar 14 17:31:45 EST 2002


[Dieter Maurer]
> Several Zope users face crashing Python 2.1.2 (SIGSEGV inside
> the garbage collector). The problem only occurs when
> the following conditions are true:
>
>   *  Zope runs in multi-threaded mode
>   *  the cyclic garbage collector is not deactivated
>
> Is the cyclic garbage collector known to be thread safe?

[Martin v. Loewis]
> The garbage collector runs while having the GIL, so it does not need
> to be thread-safe.

There's still a vulnerability here:  gc *assumes* the GIL is held when
_PyObject_GC_Malloc gets called, and doesn't verify that the GIL is in fact
held.  A rogue extension module could violate this precondition without
triggering a predictable error (and then "random" segfaults would be
likely).





More information about the Python-list mailing list