40 lines
1.6 KiB
Diff
40 lines
1.6 KiB
Diff
From 3570c9beb5398541ea7423639891ef6a9de27087 Mon Sep 17 00:00:00 2001
|
|
From: Panu Matilainen <pmatilai@redhat.com>
|
|
Date: Wed, 3 Oct 2018 11:51:38 +0300
|
|
Subject: [PATCH 1/4] Fix ancient python GIL locking bug on callback
|
|
(RhBug:1632488)
|
|
|
|
Introduced in commit c7881d801745b4c156a8aa2afc17b95f97481e34 back in 2002,
|
|
synthesizing a python object for the callback occurs before retaking
|
|
the GIL lock, which is not allowed. Somehow this has managed to stay
|
|
latent all these years, and even now requires fairly specific conditions:
|
|
when the callback gets called without an associated key, such as erasures
|
|
or file trigger script start/stop events (in the case of RhBug:1632488),
|
|
when Python 3 is running in PYTHONMALLOC=debug mode,
|
|
it crashes with "Python memory allocator called without holding the GIL".
|
|
|
|
Simply retake the lock before any Python operations take place to fix.
|
|
|
|
(cherry picked from commit 531dc8495cd3aabd3f659ecab604106fdbacbe98)
|
|
|
|
diff -urNp a/python/rpmts-py.c b/python/rpmts-py.c
|
|
--- a/python/rpmts-py.c 2019-04-22 21:07:26.880000000 +0800
|
|
+++ b/python/rpmts-py.c 2019-04-22 21:18:05.020000000 +0800
|
|
@@ -494,6 +494,8 @@ rpmtsCallback(const void * hd, const rpm
|
|
static FD_t fd;
|
|
|
|
if (cbInfo->cb == Py_None) return NULL;
|
|
+
|
|
+ PyEval_RestoreThread(cbInfo->_save);
|
|
|
|
/* Synthesize a python object for callback (if necessary). */
|
|
if (pkgObj == NULL) {
|
|
@@ -506,7 +508,6 @@ rpmtsCallback(const void * hd, const rpm
|
|
} else
|
|
Py_INCREF(pkgObj);
|
|
|
|
- PyEval_RestoreThread(cbInfo->_save);
|
|
|
|
args = Py_BuildValue("(iLLOO)", what, amount, total, pkgObj, cbInfo->data);
|
|
result = PyEval_CallObject(cbInfo->cb, args);
|