This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ocean-city
Recipients ocean-city
Date 2010-10-12.11:43:20
SpamBayes Score 2.7191429e-05
Marked as misclassified No
Message-id <1286883804.1.0.981912449546.issue10071@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, PC/winreg.c releases GIL while calling registry
API, but I found this in Remarks section of RegEnumValue.

http://msdn.microsoft.com/en-us/library/ms724865%28VS.85%29.aspx

> While using RegEnumValue, an application should not call any registry
> functions that might change the key being queried.

Maybe we shouldn't release GIL in PC/winreg.c? Thank you.

# I sometimes experienced crash of test_changing_value(test_winreg)
# on release27-maint. It happens when 2 threads calls PyEnumValue and
# PySetValue simultaneously. And I could stop it by following patch.
# I'll attach the stack trace of crash.

Index: PC/_winreg.c
===================================================================
--- PC/_winreg.c	(revision 85344)
+++ PC/_winreg.c	(working copy)
@@ -1219,7 +1219,6 @@
     }
 
     while (1) {
-        Py_BEGIN_ALLOW_THREADS
         rc = RegEnumValue(hKey,
                   index,
                   retValueBuf,
@@ -1228,7 +1227,6 @@
                   &typ,
                   (BYTE *)retDataBuf,
                   &retDataSize);
-        Py_END_ALLOW_THREADS
 
         if (rc != ERROR_MORE_DATA)
             break;
@@ -1577,9 +1575,7 @@
         if (subKey == NULL)
             return NULL;
     }
-    Py_BEGIN_ALLOW_THREADS
     rc = RegSetValue(hKey, subKey, REG_SZ, str, len+1);
-    Py_END_ALLOW_THREADS
     if (rc != ERROR_SUCCESS)
         return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue");
     Py_INCREF(Py_None);
History
Date User Action Args
2010-10-12 11:46:17ocean-cityunlinkissue10071 messages
2010-10-12 11:43:24ocean-citysetrecipients: + ocean-city
2010-10-12 11:43:24ocean-citysetmessageid: <1286883804.1.0.981912449546.issue10071@psf.upfronthosting.co.za>
2010-10-12 11:43:22ocean-citylinkissue10071 messages
2010-10-12 11:43:21ocean-citycreate