microsoft / microsoft/Power-Fx
NullRef in IExternalStringResources.TryGetErrorResource
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.4k
- Forks
- 358
- Avg merge
- 10h 34m
- Merged PRs (30d)
- 3
Description
#2514 removed a lock (to avoid a horrible performance problem from contention) - but this means now we're reading a (non-concurrent) dictionary outside of the lock. This is manifesting as race condition / non-deterministic null-ref exceptions here:
TryGet succeeds and hands back a null localizedErrorResources - likely due to a race (accessing a dictionary from multiple threads)
Naive fix is to protect this with a reader-writer lock.
Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
Dictionary`2.FindEntry(TKey key)
Dictionary`2.TryGetValue(TKey key, TValue& value)
IExternalStringResources.TryGetErrorResource(ErrorResourceKey resourceKey, ErrorResource& resourceValue, String locale)
ErrorUtils.GetLocalizedErrorContent(ErrorResourceKey errKey, CultureInfo locale, ErrorResource& errorResource)
BaseError.ctor(IDocumentError innerError, Exception internalException, DocumentErrorKind kind, DocumentErrorSeverity severity, ErrorResourceKey errKey, Span textSpan, IEnumerable`1 sinkTypeErrors, Object[] args)
BaseError.ctor(IDocumentError innerError, Exception internalException, DocumentErrorKind kind, DocumentErrorSeverity severity, ErrorResourceKey errKey, Object[] args)
TexlError.ctor(TexlNode node, DocumentErrorSeverity severity, ErrorResourceKey errKey, Object[] args)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/libraries/Microsoft.PowerFx.Core/Localization/StringResources.cs at line 234 and review the lock removal referenced in #2514. Investigate concurrent access through IExternalStringResources.TryGetErrorResource and verify that concurrent calls no longer produce a null localizedErrorResources or NullReferenceException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100