From 5b104cae71b946a9548265d66d736e0c0731dcce Mon Sep 17 00:00:00 2001 From: Max Belanger Date: Mon, 30 Oct 2017 15:48:14 -0400 Subject: [PATCH 1/3] bpo-31903: Release the GIL when calling into SystemConfiguration Make sure we release the GIL when calling `SCDynamicStoreCopyProxies` to avoid potential deadlocking if other Python threads also call into `NSUserDefaults`. --- Modules/_scproxy.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index 0e3b02879b833dc..c5660673c6357b6 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -62,7 +62,10 @@ get_proxy_settings(PyObject* mod __attribute__((__unused__))) PyObject* v; int r; + Py_BEGIN_ALLOW_THREADS proxyDict = SCDynamicStoreCopyProxies(NULL); + Py_END_ALLOW_THREADS + if (!proxyDict) { Py_RETURN_NONE; } @@ -172,7 +175,10 @@ get_proxies(PyObject* mod __attribute__((__unused__))) int r; CFDictionaryRef proxyDict = NULL; + Py_BEGIN_ALLOW_THREADS proxyDict = SCDynamicStoreCopyProxies(NULL); + Py_END_ALLOW_THREADS + if (proxyDict == NULL) { return PyDict_New(); } From a061aef1de150ec2349a09b7c3ea84325f2474e1 Mon Sep 17 00:00:00 2001 From: Max Belanger Date: Wed, 1 Nov 2017 16:53:21 -0700 Subject: [PATCH 2/3] add blurb --- Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst diff --git a/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst new file mode 100644 index 000000000000000..a96ed266f850a76 --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst @@ -0,0 +1,2 @@ +In `_scproxy`, drop the GIL when calling into `SystemConfiguration` to avoid +deadlocks. From 2b464f12190e870197261891aa6eeb8cbd97ffab Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 11 Sep 2018 15:17:01 -0700 Subject: [PATCH 3/3] fix reST --- Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst index a96ed266f850a76..3788112cd730299 100644 --- a/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst +++ b/Misc/NEWS.d/next/macOS/2017-11-01-16-53-12.bpo-31903.K6jCVG.rst @@ -1,2 +1,2 @@ -In `_scproxy`, drop the GIL when calling into `SystemConfiguration` to avoid +In :mod:`_scproxy`, drop the GIL when calling into ``SystemConfiguration`` to avoid deadlocks.