Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
PyDict_Next currently wraps_PyDict_Next in a critical section. We shouldn't do this -- the locking needs to be external to the call.
- It's not sufficient to lock the dict just for each
_PyDict_Nextcall because we return borrowed references and becauseposbecomes meaningless if the dictionary gets resized or rehashed. - It interferes with externally locking the dict because the inner critical sections can suspend the outer ones. In other words, if the caller use a critical section to lock the dict for multiple iterations, this will break that.
Lines 2883 to 2890 in8f17d69
| PyDict_Next(PyObject*op,Py_ssize_t*ppos,PyObject**pkey,PyObject**pvalue) | |
| { | |
| intres; | |
| Py_BEGIN_CRITICAL_SECTION(op); | |
| res=_PyDict_Next(op,ppos,pkey,pvalue,NULL); | |
| Py_END_CRITICAL_SECTION(); | |
| returnres; | |
| } |
cc@DinoV