Prevent occasional deadlock
@@ -146,10 +146,13 @@ namespace IronPython.Runtime {
private int _tracebackListenersCount;
internal FunctionCode.CodeList _allCodes;
- internal readonly object _codeCleanupLock = new object(), _codeUpdateLock = new object();
+ internal readonly object _codeCleanupLock = new object();
+ internal readonly object _codeUpdateLock = new object();
internal int _codeCount, _nextCodeCleanup = 200;
private int _recursionLimit;
+ private readonly object _indexBindersLock = new object(); // https://github.com/IronLanguages/ironpython3/issues/1596
+
internal readonly List<FunctionStack> _mainThreadFunctionStack;
private CallSite<Func<CallSite, CodeContext, object, object>> _callSite0LightEh;
private List<WeakReference> _weakExtensionMethodSets;
@@ -3579,7 +3582,7 @@ namespace IronPython.Runtime {
Interlocked.CompareExchange(ref _getIndexBinders, new PythonGetIndexBinder[argCount + 1], null);
}
- lock (this) {
+ lock (_indexBindersLock) {
if (_getIndexBinders.Length <= argCount) {
Array.Resize(ref _getIndexBinders, argCount + 1);
}
@@ -3597,7 +3600,7 @@ namespace IronPython.Runtime {
Interlocked.CompareExchange(ref _setIndexBinders, new PythonSetIndexBinder[argCount + 1], null);
}
- lock (this) {
+ lock (_indexBindersLock) {
if (_setIndexBinders.Length <= argCount) {
Array.Resize(ref _setIndexBinders, argCount + 1);
}
@@ -3615,7 +3618,7 @@ namespace IronPython.Runtime {
Interlocked.CompareExchange(ref _deleteIndexBinders, new PythonDeleteIndexBinder[argCount + 1], null);
}
- lock (this) {
+ lock (_indexBindersLock) {
if (_deleteIndexBinders.Length <= argCount) {
Array.Resize(ref _deleteIndexBinders, argCount + 1);
}
