summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-02-07 02:29:31 -0800
committerJan Kotas <jkotas@microsoft.com>2015-02-07 02:29:31 -0800
commit9df15b9fdfb55ce2076a5e7eede8ca71481e5e3b (patch)
tree9eb6069016b38bbdcfb37e89ad37a9698e21f470 /src
parentd07864bf154b53874784cd956db6f25548e4d0fa (diff)
parenteedb57dff27884ee4d3539ce3eda283408aea3ae (diff)
downloadcoreclr-9df15b9fdfb55ce2076a5e7eede8ca71481e5e3b.tar.gz
coreclr-9df15b9fdfb55ce2076a5e7eede8ca71481e5e3b.tar.bz2
coreclr-9df15b9fdfb55ce2076a5e7eede8ca71481e5e3b.zip
Merge pull request #75 from PashaPash/resourceset_deadlock
Fixed deadlock in System.Resources.ResourceSet
Diffstat (limited to 'src')
-rw-r--r--src/mscorlib/src/System/Resources/ResourceReader.cs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/mscorlib/src/System/Resources/ResourceReader.cs b/src/mscorlib/src/System/Resources/ResourceReader.cs
index 4430ca6328..a811fae194 100644
--- a/src/mscorlib/src/System/Resources/ResourceReader.cs
+++ b/src/mscorlib/src/System/Resources/ResourceReader.cs
@@ -1373,22 +1373,24 @@ namespace System.Resources {
String key;
Object value = null;
- lock (_reader._resCache) {
- key = _reader.AllocateStringForNameIndex(_currentName, out _dataPosition);
- ResourceLocator locator;
- if (_reader._resCache.TryGetValue(key, out locator)) {
- value = locator.Value;
- }
- if (value == null) {
- if (_dataPosition == -1)
- value = _reader.GetValueForNameIndex(_currentName);
- else
- value = _reader.LoadObject(_dataPosition);
- // If enumeration and subsequent lookups happen very
- // frequently in the same process, add a ResourceLocator
- // to _resCache here. But WinForms enumerates and
- // just about everyone else does lookups. So caching
- // here may bloat working set.
+ lock (_reader) { // locks should be taken in the same order as in RuntimeResourceSet.GetObject to avoid deadlock
+ lock (_reader._resCache) {
+ key = _reader.AllocateStringForNameIndex(_currentName, out _dataPosition); // AllocateStringForNameIndex could lock on _reader
+ ResourceLocator locator;
+ if (_reader._resCache.TryGetValue(key, out locator)) {
+ value = locator.Value;
+ }
+ if (value == null) {
+ if (_dataPosition == -1)
+ value = _reader.GetValueForNameIndex(_currentName);
+ else
+ value = _reader.LoadObject(_dataPosition);
+ // If enumeration and subsequent lookups happen very
+ // frequently in the same process, add a ResourceLocator
+ // to _resCache here. But WinForms enumerates and
+ // just about everyone else does lookups. So caching
+ // here may bloat working set.
+ }
}
}
return new DictionaryEntry(key, value);