Skip to content

Commit 976c0be

Browse files
rolfbjarneCopilot
andcommitted
[tests] Ignore the CoreCLR 'dotnet watch' tests on the mobile platforms.
Hot Reload with CoreCLR is currently broken on iOS and Mac Catalyst: the app crashes right after the update has been applied: dotnet watch ⌚ File updated: .../AdditionalFile.cs Unhandled exception. System.BadImageFormatException: Bad IL range. at HotReloadTestApp.Program.DoSomething(Int32 i) at HotReloadTestApp.Program.RunTestLogic() at HotReloadTestApp.Program.Main(String[] args) dotnet watch ❌ [HotReloadTestApp (net11.0-maccatalyst)] Exited with error code 134 The "Bad IL range" error comes from CoreCLR's PEAssembly::GetIL, which means the runtime looked up the updated method's IL in the *baseline* PE image using the RVA from the metadata delta - and that RVA is delta-relative, so it's out of range in the baseline image. In other words the runtime didn't pick up the delta IL when compiling the updated method. This is fallout from dotnet/runtime#130159 ("Use CodeVersioning for EnC"), which made the delta IL be stored as an ILCodeVersion: only VersionedPrepareCodeConfig::GetILHeader returns it, while the plain PrepareCodeConfig::GetILHeader falls back to MethodDesc::GetILHeader (= the baseline RVA lookup that ends up throwing). So something prepares the updated method with a non-versioned config on the affected platforms. Note that the mobile difference is *not* code versioning as such - that's enabled everywhere, since FEATURE_METADATA_UPDATER turns on FEATURE_CODE_VERSIONING, and MethodDesc::IsEligibleForEnC doesn't depend on tiered compilation. What actually differs is that FEATURE_DYNAMIC_CODE_COMPILED is off for Apple mobile, so there's no JIT and these apps run the CoreCLR interpreter instead. That's also why desktop macOS is unaffected. Nothing we can do about this on our side, so just ignore the affected test cases for now. The Mono test cases and the desktop macOS test cases still run. Tracked upstream in dotnet/runtime#132804, and in #26470 on our side. Re-enable these test cases once the fix has flowed into our runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ac84fef commit 976c0be

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/dotnet/UnitTests/DotNetWatchTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ void DotNetWatchImpl (ApplePlatform platform, bool useMonoRuntime, bool enableSa
5555
{
5656
Configuration.IgnoreIfIgnoredPlatform (platform);
5757

58+
// Hot Reload with CoreCLR is currently broken on the mobile platforms: the app crashes with
59+
// "System.BadImageFormatException: Bad IL range" right after the update has been applied.
60+
// Desktop macOS is not affected.
61+
//
62+
// That error comes from CoreCLR's PEAssembly::GetIL, which means the runtime looked up the
63+
// updated method's IL in the *baseline* PE image using the RVA from the metadata delta - and
64+
// that RVA is delta-relative, so it's out of range in the baseline image. In other words the
65+
// runtime didn't pick up the delta IL when compiling the updated method.
66+
//
67+
// This is fallout from https://github.com/dotnet/runtime/pull/130159 ("Use CodeVersioning for
68+
// EnC"), which made the delta IL be stored as an ILCodeVersion: only
69+
// VersionedPrepareCodeConfig::GetILHeader returns it, while the plain
70+
// PrepareCodeConfig::GetILHeader falls back to MethodDesc::GetILHeader (= the baseline RVA
71+
// lookup that ends up throwing). Something on the mobile-only code path prepares the updated
72+
// method with a non-versioned config. The mobile difference isn't code versioning as such
73+
// (that's enabled everywhere, since FEATURE_METADATA_UPDATER turns on FEATURE_CODE_VERSIONING),
74+
// but rather that FEATURE_DYNAMIC_CODE_COMPILED is off for Apple mobile, so there's no JIT and
75+
// these apps run the CoreCLR interpreter instead.
76+
//
77+
// Tracked upstream here: https://github.com/dotnet/runtime/issues/132804
78+
// Re-enable these test cases once the fix has flowed into our runtime.
79+
if (!useMonoRuntime && platform != ApplePlatform.MacOSX)
80+
Assert.Ignore ("Hot Reload with CoreCLR is currently broken on this platform: https://github.com/dotnet/macios/issues/26470");
81+
5882
var projectPath = GetProjectPath ("HotReloadTestApp", platform: platform);
5983
var projectDirectory = Path.GetDirectoryName (projectPath)!;
6084

0 commit comments

Comments
 (0)