Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wasm][AOT] Assertion at /__w/1/s/runtime/src/mono/mono/mini/exceptions-wasm.c:66, condition `(*lmf)->method #46613

Closed
jeromelaban opened this issue Jan 6, 2021 · 5 comments · Fixed by #47144, mono/mono#20758 or unoplatform/Uno.Wasm.Bootstrap#335
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Milestone

Comments

@jeromelaban
Copy link
Contributor

Description

Executing the following code:

try
{
	var asm = Assembly.Load(new AssemblyName("invalid.resources"));
	Console.WriteLine("asm: " + asm);
}
catch
{
	Console.WriteLine("not found");
}

var s = typeof(Program).Assembly.GetSatelliteAssembly(CultureInfo.InvariantCulture);

fails with the following:

* Assertion at /__w/1/s/runtime/src/mono/mono/mini/exceptions-wasm.c:66, condition `(*lmf)->method' not met
mono_assertion_message | @ | 03e207c6:0x23f595
-- | -- | --
  | mono_arch_unwind_frame | @ | 03e207c6:0x30f8df
  | arch_unwind_frame | @ | 03e207c6:0x301bfa
  | mono_find_jit_info_ext | @ | 03e207c6:0x301caf
  | unwinder_unwind_frame | @ | 03e207c6:0x3026c1
  | mono_walk_stack_full | @ | 03e207c6:0x3015e8
  | mono_walk_stack_with_ctx | @ | 03e207c6:0x301448
  | mono_runtime_walk_stack_with_ctx | @ | 03e207c6:0x3011b6
  | mono_stack_walk_no_il | @ | 03e207c6:0x278931
  | mono_runtime_get_caller_from_stack_mark | @ | 03e207c6:0x262951
  | ves_icall_System_Reflection_Assembly_InternalLoad | @ | 03e207c6:0x246e8d
  | ves_icall_System_Reflection_Assembly_InternalLoad_raw | @ | 03e207c6:0x26ce78
  | aot_wrapper_corlib_System_dot_Reflection_System_dot_Reflection_dot_Assembly__InternalLoad_pinvoke_cls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_iicls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_ii | @ | 03e207c6:0x13538b
  | corlib_System_Reflection_Assembly_Load_System_Reflection_AssemblyName_System_Threading_StackCrawlMark__System_Runtime_Loader_AssemblyLoadContext | @ | 03e207c6:0x1350d2
  | invoke_iiiii | @ | dotnet.js:11666
  | corlib_System_Reflection_RuntimeAssembly_InternalGetSatelliteAssembly_System_Reflection_Assembly_System_Globalization_CultureInfo_System_Version_bool | @ | 03e207c6:0x122526
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo_System_Version | @ | 03e207c6:0x13b87d
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo | @ | 03e207c6:0x13b800
  | Bug45698__Program___Main__string__


Configuration

73bce55

Regression?

No.

Other information

Related to #45698

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Jan 6, 2021
@ghost
Copy link

ghost commented Jan 6, 2021

Tagging subscribers to this area: @CoffeeFlux
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Executing the following code:

try
{
	var asm = Assembly.Load(new AssemblyName("invalid.resources"));
	Console.WriteLine("asm: " + asm);
}
catch
{
	Console.WriteLine("not found");
}

var s = typeof(Program).Assembly.GetSatelliteAssembly(CultureInfo.InvariantCulture);

fails with the following:

* Assertion at /__w/1/s/runtime/src/mono/mono/mini/exceptions-wasm.c:66, condition `(*lmf)->method' not met
mono_assertion_message | @ | 03e207c6:0x23f595
-- | -- | --
  | mono_arch_unwind_frame | @ | 03e207c6:0x30f8df
  | arch_unwind_frame | @ | 03e207c6:0x301bfa
  | mono_find_jit_info_ext | @ | 03e207c6:0x301caf
  | unwinder_unwind_frame | @ | 03e207c6:0x3026c1
  | mono_walk_stack_full | @ | 03e207c6:0x3015e8
  | mono_walk_stack_with_ctx | @ | 03e207c6:0x301448
  | mono_runtime_walk_stack_with_ctx | @ | 03e207c6:0x3011b6
  | mono_stack_walk_no_il | @ | 03e207c6:0x278931
  | mono_runtime_get_caller_from_stack_mark | @ | 03e207c6:0x262951
  | ves_icall_System_Reflection_Assembly_InternalLoad | @ | 03e207c6:0x246e8d
  | ves_icall_System_Reflection_Assembly_InternalLoad_raw | @ | 03e207c6:0x26ce78
  | aot_wrapper_corlib_System_dot_Reflection_System_dot_Reflection_dot_Assembly__InternalLoad_pinvoke_cls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_iicls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_ii | @ | 03e207c6:0x13538b
  | corlib_System_Reflection_Assembly_Load_System_Reflection_AssemblyName_System_Threading_StackCrawlMark__System_Runtime_Loader_AssemblyLoadContext | @ | 03e207c6:0x1350d2
  | invoke_iiiii | @ | dotnet.js:11666
  | corlib_System_Reflection_RuntimeAssembly_InternalGetSatelliteAssembly_System_Reflection_Assembly_System_Globalization_CultureInfo_System_Version_bool | @ | 03e207c6:0x122526
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo_System_Version | @ | 03e207c6:0x13b87d
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo | @ | 03e207c6:0x13b800
  | Bug45698__Program___Main__string__


Configuration

73bce55

Regression?

No.

Other information

Related to #45698

Author: jeromelaban
Assignees: -
Labels:

area-VM-meta-mono, untriaged

Milestone: -

@vargaz
Copy link
Contributor

vargaz commented Jan 7, 2021

The current way we handle stack walks is not good enough, we push lmf frames and don't pop them on an exception, so they get corrupted.

@lewing lewing added this to the 6.0.0 milestone Jan 14, 2021
@lewing lewing added the arch-wasm WebAssembly architecture label Jan 14, 2021
@ghost
Copy link

ghost commented Jan 14, 2021

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Executing the following code:

try
{
	var asm = Assembly.Load(new AssemblyName("invalid.resources"));
	Console.WriteLine("asm: " + asm);
}
catch
{
	Console.WriteLine("not found");
}

var s = typeof(Program).Assembly.GetSatelliteAssembly(CultureInfo.InvariantCulture);

fails with the following:

* Assertion at /__w/1/s/runtime/src/mono/mono/mini/exceptions-wasm.c:66, condition `(*lmf)->method' not met
mono_assertion_message | @ | 03e207c6:0x23f595
-- | -- | --
  | mono_arch_unwind_frame | @ | 03e207c6:0x30f8df
  | arch_unwind_frame | @ | 03e207c6:0x301bfa
  | mono_find_jit_info_ext | @ | 03e207c6:0x301caf
  | unwinder_unwind_frame | @ | 03e207c6:0x3026c1
  | mono_walk_stack_full | @ | 03e207c6:0x3015e8
  | mono_walk_stack_with_ctx | @ | 03e207c6:0x301448
  | mono_runtime_walk_stack_with_ctx | @ | 03e207c6:0x3011b6
  | mono_stack_walk_no_il | @ | 03e207c6:0x278931
  | mono_runtime_get_caller_from_stack_mark | @ | 03e207c6:0x262951
  | ves_icall_System_Reflection_Assembly_InternalLoad | @ | 03e207c6:0x246e8d
  | ves_icall_System_Reflection_Assembly_InternalLoad_raw | @ | 03e207c6:0x26ce78
  | aot_wrapper_corlib_System_dot_Reflection_System_dot_Reflection_dot_Assembly__InternalLoad_pinvoke_cls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_iicls14_Reflection_dAssembly__cl6_string_bcls1c_Threading_dStackCrawlMark_26_ii | @ | 03e207c6:0x13538b
  | corlib_System_Reflection_Assembly_Load_System_Reflection_AssemblyName_System_Threading_StackCrawlMark__System_Runtime_Loader_AssemblyLoadContext | @ | 03e207c6:0x1350d2
  | invoke_iiiii | @ | dotnet.js:11666
  | corlib_System_Reflection_RuntimeAssembly_InternalGetSatelliteAssembly_System_Reflection_Assembly_System_Globalization_CultureInfo_System_Version_bool | @ | 03e207c6:0x122526
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo_System_Version | @ | 03e207c6:0x13b87d
  | corlib_System_Reflection_RuntimeAssembly_GetSatelliteAssembly_System_Globalization_CultureInfo | @ | 03e207c6:0x13b800
  | Bug45698__Program___Main__string__


Configuration

73bce55

Regression?

No.

Other information

Related to #45698

Author: jeromelaban
Assignees: vargaz
Labels:

arch-wasm, area-VM-meta-mono, untriaged

Milestone: 6.0.0

@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Jan 14, 2021
@jeromelaban
Copy link
Contributor Author

jeromelaban commented Jan 15, 2021

Recent changes (likely #45078) make the problem bigger as afterwards the execution gets stuck in an infinite loop in various places (always using mixed mode).

vargaz added a commit to vargaz/runtime that referenced this issue Jan 19, 2021
…F code might not get executed in case of an exception.

Fixes dotnet#46613.
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 19, 2021
vargaz added a commit that referenced this issue Jan 20, 2021
…F code might not get executed in case of an exception. (#47144)

* Pop LMF frames in exception handlers on wasm, since the normal pop LMF code might not get executed in case of an exception.

Fixes #46613.

* Update src/mono/mono/mini/llvmonly-runtime.c

Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>

Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 20, 2021
vargaz added a commit to monojenkins/mono that referenced this issue Jan 20, 2021
…F code might not get executed in case of an exception.

Fixes dotnet/runtime#46613.
vargaz added a commit to mono/mono that referenced this issue Jan 20, 2021
…F code might not get executed in case of an exception. (#20758)

Fixes dotnet/runtime#46613.

Co-authored-by: vargaz <[email protected]>
jeromelaban added a commit to unoplatform/Uno.DotnetRuntime.WebAssembly that referenced this issue Jan 20, 2021
jeromelaban added a commit to unoplatform/Uno.Wasm.Bootstrap that referenced this issue Jan 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.