You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ResourceLoader.AddLookupAssembly rollback can leave partially parsed .upri values observable #23959
AddLookupAssembly now removes a failed assembly registration and its parsed-resource markers when parsing throws. However, ProcessResourceFile mutates the live loader incrementally:
it records the parsed marker;
it obtains the live _resources dictionary;
it writes each parsed pair with resources[key] = value.
If a valid .upri declares multiple entries, successfully parses and writes the first entry, then is truncated before a later key/value, BinaryReader.ReadString throws EndOfStreamException (IOException). The AddLookupAssembly catch removes the assembly from _lookupAssemblies and removes its markers, but does not restore the already-mutated live resource dictionaries.
The result can be an unregistered assembly whose partially parsed resource value remains observable.
The regression added in #23707 uses an invalid magic and therefore throws before the marker or live resource dictionary is mutated; it does not cover this partial-parse case.
Expected behavior
A failed AddLookupAssembly call should be transactional: after it throws, no registration, parsed marker, or resource value contributed by that attempt should remain observable.
Regression scenario
Emit a .upri with:
a valid header, loader and culture;
resourceCount = 2;
one complete key/value pair;
a truncated stream before the second pair.
Then assert:
AddLookupAssembly throws the expected data/I/O exception;
ContainsLookupAssembly(assembly) is false;
the first value is not visible from the loader.
Suggested direction
Parse the assembly into temporary dictionaries and apply them only after every .upri succeeds, or rebuild live resource state from surviving registrations when registration fails.
Observed by source inspection on merged PR head 1e6b388c77ed51be12b53dc16920b8a8d9ea4249 / merge commit 2fc0049a2568a3e749fe0efb4259da64c9124c91.
Fix opened as #23960: AddLookupAssembly now parses a newly registered assembly's .upri files into temporary dictionaries and merges them into the live loaders only after every file parsed successfully (mirroring RebuildLoaderResourcesFromSurvivors), and the full-reload failure path re-derives the merged state from the surviving registrations. Includes red/green regression tests for the truncated-.upri scenario covering both parse branches.
Activity
nickrandolph commentedon Aug 4, 2026
Fix opened as #23960:
AddLookupAssemblynow parses a newly registered assembly's.uprifiles into temporary dictionaries and merges them into the live loaders only after every file parsed successfully (mirroringRebuildLoaderResourcesFromSurvivors), and the full-reload failure path re-derives the merged state from the surviving registrations. Includes red/green regression tests for the truncated-.upriscenario covering both parse branches.fix(resources): make AddLookupAssembly transactional on parse failure