Skip to content

Commit

Permalink
[runtime] Improve error reporting when calling mono_assembly_open. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Jun 3, 2022
1 parent 0e5b2c3 commit 6bccb1f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions runtime/coreclr-bridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,13 @@
MonoAssembly *
mono_assembly_open (const char * filename, MonoImageOpenStatus * status)
{
assert (status == NULL);

MonoAssembly *rv = xamarin_find_assembly (filename);

LOG_CORECLR (stderr, "mono_assembly_open (%s, %p) => MonoObject=%p GCHandle=%p\n", filename, status, rv, rv->gchandle);

if (status != NULL)
*status = rv == NULL ? MONO_IMAGE_ERROR_ERRNO : MONO_IMAGE_OK;

return rv;
}

Expand Down
27 changes: 14 additions & 13 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -917,22 +917,27 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
return stat (path, &buffer) == 0;
}

static MonoAssembly *
xamarin_open_assembly_or_assert (const char *name)
{
MonoImageOpenStatus status = MONO_IMAGE_OK;
MonoAssembly *assembly = mono_assembly_open (name, &status);
if (assembly == NULL)
xamarin_assertion_message ("Failed to open the assembly '%s' from the app: %i (errno: %i). This is usually fixed by cleaning and rebuilding your project; if that doesn't work, please file a bug report: https://github.com/xamarin/xamarin-macios/issues/new", name, (int) status, errno);
return assembly;
}

// Returns a retained MonoObject. Caller must release.
MonoAssembly *
xamarin_open_assembly (const char *name)
{
// COOP: this is a function executed only at startup, I believe the mode here doesn't matter.
char path [1024];
MonoAssembly *assembly;
bool exists = false;

#if MONOMAC
if (xamarin_get_is_mkbundle ()) {
assembly = mono_assembly_open (name, NULL);
if (assembly == NULL)
xamarin_assertion_message ("Could not find the required assembly '%s' in the app. This is usually fixed by cleaning and rebuilding your project; if that doesn't work, please file a bug report: https://github.com/xamarin/xamarin-macios/issues/new", name);
return assembly;
}
if (xamarin_get_is_mkbundle ())
return xamarin_open_assembly_or_assert (name);
#endif

exists = xamarin_locate_assembly_resource (name, NULL, name, path, sizeof (path));
Expand All @@ -942,7 +947,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
// Check if we already have the assembly in memory
xamarin_get_assembly_name_without_extension (name, path, sizeof (path));
MonoAssemblyName *aname = mono_assembly_name_new (path);
assembly = mono_assembly_loaded (aname);
MonoAssembly *assembly = mono_assembly_loaded (aname);
mono_assembly_name_free (aname);
if (assembly)
return assembly;
Expand All @@ -954,11 +959,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
if (!exists)
xamarin_assertion_message ("Could not find the assembly '%s' in the app. This is usually fixed by cleaning and rebuilding your project; if that doesn't work, please file a bug report: https://github.com/xamarin/xamarin-macios/issues/new", name);

assembly = mono_assembly_open (path, NULL);
if (assembly == NULL)
xamarin_assertion_message ("Could not find the required assembly '%s' in the app. This is usually fixed by cleaning and rebuilding your project; if that doesn't work, please file a bug report: https://github.com/xamarin/xamarin-macios/issues/new", name);

return assembly;
return xamarin_open_assembly_or_assert (path);
}

bool
Expand Down

5 comments on commit 6bccb1f

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Tests on macOS M1 - Mac Big Sur (11.5) failed for unknown reasons.

Pipeline on Agent
Hash: 6bccb1f1d36eea5f29b29f2a330e99c2634fc10c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 6bccb1f1d36eea5f29b29f2a330e99c2634fc10c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 [CI Build] API Diff 📋

API diff (for current PR)

ℹ️ API Diff (from PR only) (please review changes)

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

API diff (vs stable)

✅ API Diff from stable

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMMINI-057.Monterey'
Hash: 6bccb1f1d36eea5f29b29f2a330e99c2634fc10c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-067.Monterey'
Hash: 6bccb1f1d36eea5f29b29f2a330e99c2634fc10c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

7 tests failed, 227 tests passed.

Failed tests

  • fsharp/watchOS 32-bits - simulator/Debug: Crashed
  • [NUnit] Mono SystemXmlTests/watchOS 32-bits - simulator/Debug: Crashed
  • [xUnit] Mono MicrosoftCSharpXunit/watchOS 32-bits - simulator/Debug: Crashed
  • mscorlib Part 2/watchOS 32-bits - simulator/Debug: Crashed
  • [xUnit] Mono SystemCoreXunit Part 2/watchOS 32-bits - simulator/Debug: Crashed
  • monotouch-test/watchOS 32-bits - simulator/Release (all optimizations): TimedOut
  • monotouch-test/watchOS 32-bits - simulator/Debug (all optimizations): Crashed

Pipeline on Agent XAMBOT-1033.Monterey'
[runtime] Improve error reporting when calling mono_assembly_open. (#15139)

Please sign in to comment.