Regression introduced in .net9 preview 5, and still present in rc1. On iOS, certain code that worked on .net9 preview 4 and all previous versions of .net now crashes with InvalidProgramException in release builds.
Triggering code is a path of DryIoc's interpreter. From what I could isolate, it occurs in these circumstances:
multiple singleton service types (A, B, depend on another singleton type Z)
the Z type is injected lazily (Lazy<Z> constructor parameter)
DryIoC is configured to use its own interpreter
DryIoC attempts to resolve one of the service types (e.g. B), after having previously resolved the other service type (e.g. A)
Circumstances that don't cause it:
Z type is injected directly, not lazily
Only one of the service types is resolved, including repeated resolutions of the same type.
Tagging @dadhi the library author who may be able to provide information on what specific parts of the interpreter are exercised in this "resolution of second service injecting lazy dependency" case that differ from the cases that don't trigger the crash.
Reproduction Steps
be running .net9 p5 or later, with the ios workload installed
Application launches and remains running with log output:
Resolve a service that depends on Lazy<Thing> once
Ok
Resolve the same service that depends on Lazy<Thing> a second time
Ok
Resolve a different service that depends on Lazy<Thing>
Ok
Actual behavior
Application launches and quickly crashes, with log output:
Resolve a service that depends on Lazy<Thing> once
Ok
Resolve the same service that depends on Lazy<Thing> a second time
Ok
Resolve a different service that depends on Lazy<Thing>
Terminating app due to uncaught exception 'System.InvalidProgramException', reason: ' (System.InvalidProgramException)
at DryIoc.Interpreter.TryInterpretSingletonAndUnwrapContainerException(IResolverContext r, Expression expr, ImMapEntry`1 itemRef, Object& result)
at DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request) at DryIoc.Factory.GetExpressionOrDefault(Request request)
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
at DryIoc.Resolver.Resolve[IServiceB](IResolver resolver, IfUnresolved ifUnresolved)
at InvalidProgram.AppDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions)
at InvalidProgram.AppDelegate.Registrar_Callbacks.callback_2_InvalidProgram_AppDelegate_FinishedLaunching(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle) '
(sometimes, app may crash before exception details are written to console)
Regression?
Yes. This was working in .net9 preview 4 and earlier stables.
Introduced in .net9 preview 5 and still present in .net9 rc1.
Tagging subscribers to 'os-ios': @vitek-karas, @kotlarmilos, @ivanpovazan, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.
Description
Regression introduced in .net9 preview 5, and still present in rc1. On iOS, certain code that worked on .net9 preview 4 and all previous versions of .net now crashes with
InvalidProgramException
in release builds.Triggering code is a path of DryIoc's interpreter. From what I could isolate, it occurs in these circumstances:
A
,B
, depend on another singleton typeZ
)Z
type is injected lazily (Lazy<Z>
constructor parameter)B
), after having previously resolved the other service type (e.g.A
)Circumstances that don't cause it:
Z
type is injected directly, not lazilyTagging @dadhi the library author who may be able to provide information on what specific parts of the interpreter are exercised in this "resolution of second service injecting lazy dependency" case that differ from the cases that don't trigger the crash.
Reproduction Steps
ios
workload installed./net9.sh {Your Physical Device UDID}
Expected behavior
Application launches and remains running with log output:
Actual behavior
Application launches and quickly crashes, with log output:
(sometimes, app may crash before exception details are written to console)
Regression?
Yes. This was working in .net9 preview 4 and earlier stables. Introduced in .net9 preview 5 and still present in .net9 rc1.
Known Workarounds
No response
Configuration
dotnet --info
Other information
No response