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

[.NET 7.0 + WASM AOT] Assembly.GetName().Name crashes the app #79814

Closed
DierkDroth opened this issue Dec 19, 2022 · 11 comments
Closed

[.NET 7.0 + WASM AOT] Assembly.GetName().Name crashes the app #79814

DierkDroth opened this issue Dec 19, 2022 · 11 comments
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Milestone

Comments

@DierkDroth
Copy link

Description

@vargaz I came across another WASM AOT crash where @jeromelaban pointed me here.

I'll copy the details of my original report for your convenience ... and please believe me, for the whole weekend I (successfully) isolated the issue in my app and (unsuccessfully) tried to create a repo, but again failed ... so, again no repo :-(

I isolated an AOT crash where adding the line
var o = GetType().Assembly.GetName().Name;
... to my app's code crashes the app (screenshow and logs below).

Interestingly I have the line below right before the offending line above in my code and this itself does not cause any issues
collection-which-is-not-empty.FirstOrDefault(o => o.Name == assembly.GetName().Name && o.Version == assembly.GetName().Version.ToString(3)) == null

And it's getting even more weird: if I commented out the offending line, then the app would work as expected - of course. But if I 'commented' it out by

#if !HAS_UNO_WASM
var o = GetType().Assembly.GetName().Name;
#endif

... then the app still would crash?!? Really?!? Go figure...

Unfortunately I was unable to create a repo - although the issue itself is 100% reproducible by only adding the offending line above to my app. So, another WASM AOT mystery ... :-(

Would you have any idea idea what might be causing the issue?

1671438561270.zip

dotnet.js:1149 2022-12-19 08:27:21:693 (df574c21-3788-4807-9e52-2d6a793ca322) Common.Session.ConnectDbAsync: useLocalDb=False
dotnet.js:5 Error: [MONO] * Assertion at D:/a/Uno.DotnetRuntime.WebAssembly/Uno.DotnetRuntime.WebAssembly/runtime/src/mono/mono/mini/interp/interp.c:2557, condition `is_ok (error)' not met, function:init_jit_call_info, Attempting to JIT compile method '(wrapper other) void modreq(System.Runtime.CompilerServices.IsExternalInit) object:gsharedvt_out_sig (object&,intptr)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
 assembly:<unknown assembly> type:<unknown type> member:(null)

    at mono_wasm_stringify_as_error_with_stack (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5:620)
    at Object.mono_wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5:985)
    at _mono_wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5034:66)
    at wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at eglib_log_adapter (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at monoeg_g_logv_nofree (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at monoeg_assertion_message (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at do_jit_call (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at interp_exec_method (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at interp_runtime_invoke (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
mono_wasm_trace_logger @ dotnet.js:5

Reproduction Steps

Please see above

Expected behavior

Please see above

Actual behavior

Please see above

Regression?

No response

Known Workarounds

None

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 19, 2022
@vargaz
Copy link
Contributor

vargaz commented Dec 19, 2022

This is a testcase which is supposed to hit the relevant code path:

using System;

public class Test
{
    public string Prop
    {
        get { return "A"; }
        init { }
    }

    public static void Main () {
        try {
            throw new Exception ();
        } catch {
            var t = new Test () { Prop = "B" };
        }
    }
}

However, it doesn't cause a crash with dotnet/runtime HEAD.

@DierkDroth
Copy link
Author

@vargaz thanks for looking into.

Curious: I don't see Assembly.GetName().Name in your sample - which is what makes my app crash.

What am I missing?

@marek-safar marek-safar added the arch-wasm WebAssembly architecture label Dec 20, 2022
@ghost
Copy link

ghost commented Dec 20, 2022

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

Issue Details

Description

@vargaz I came across another WASM AOT crash where @jeromelaban pointed me here.

I'll copy the details of my original report for your convenience ... and please believe me, for the whole weekend I (successfully) isolated the issue in my app and (unsuccessfully) tried to create a repo, but again failed ... so, again no repo :-(

I isolated an AOT crash where adding the line
var o = GetType().Assembly.GetName().Name;
... to my app's code crashes the app (screenshow and logs below).

Interestingly I have the line below right before the offending line above in my code and this itself does not cause any issues
collection-which-is-not-empty.FirstOrDefault(o => o.Name == assembly.GetName().Name && o.Version == assembly.GetName().Version.ToString(3)) == null

And it's getting even more weird: if I commented out the offending line, then the app would work as expected - of course. But if I 'commented' it out by

#if !HAS_UNO_WASM
var o = GetType().Assembly.GetName().Name;
#endif

... then the app still would crash?!? Really?!? Go figure...

Unfortunately I was unable to create a repo - although the issue itself is 100% reproducible by only adding the offending line above to my app. So, another WASM AOT mystery ... :-(

Would you have any idea idea what might be causing the issue?

1671438561270.zip

dotnet.js:1149 2022-12-19 08:27:21:693 (df574c21-3788-4807-9e52-2d6a793ca322) Common.Session.ConnectDbAsync: useLocalDb=False
dotnet.js:5 Error: [MONO] * Assertion at D:/a/Uno.DotnetRuntime.WebAssembly/Uno.DotnetRuntime.WebAssembly/runtime/src/mono/mono/mini/interp/interp.c:2557, condition `is_ok (error)' not met, function:init_jit_call_info, Attempting to JIT compile method '(wrapper other) void modreq(System.Runtime.CompilerServices.IsExternalInit) object:gsharedvt_out_sig (object&,intptr)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
 assembly:<unknown assembly> type:<unknown type> member:(null)

    at mono_wasm_stringify_as_error_with_stack (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5:620)
    at Object.mono_wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5:985)
    at _mono_wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.js:5034:66)
    at wasm_trace_logger (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at eglib_log_adapter (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at monoeg_g_logv_nofree (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at monoeg_assertion_message (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at do_jit_call (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at interp_exec_method (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
    at interp_runtime_invoke (Latest/package_34f078c37648e985421d5e6a0dc211630a4e3da0/dotnet.wasm)
mono_wasm_trace_logger @ dotnet.js:5

Reproduction Steps

Please see above

Expected behavior

Please see above

Actual behavior

Please see above

Regression?

No response

Known Workarounds

None

Configuration

No response

Other information

No response

Author: DierkDroth
Assignees: -
Labels:

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

Milestone: -

@vargaz
Copy link
Contributor

vargaz commented Dec 20, 2022

The testcase should hit the code path inside the runtime which contains the failed assertion. Unfortunately, it doesn't reproduce the problem for me.

@DierkDroth
Copy link
Author

@vargaz thanks again.

Is there anything else I could try to isolate the issue (although every iteration will take ~1 hour due to the time needed to do the AOT build)?

@vargaz
Copy link
Contributor

vargaz commented Jan 2, 2023

If you add the testcase code to the app, does it cause it to crash ?

@DierkDroth
Copy link
Author

DierkDroth commented Jan 2, 2023

@vargaz thanks for getting back to me.

Please find below what I see when adding your code above to my app and executing it like:

try
{ 
	Test.Main();
}
catch
{
	// does not make it here
}

Does this help?

image

@vargaz
Copy link
Contributor

vargaz commented Jan 2, 2023

Does it also fail if you add the testcase to an empty uno app ?

@vargaz
Copy link
Contributor

vargaz commented Jan 2, 2023

Also, can you try to get a verbose build log (/v:d argument to msbuild) ?

@DierkDroth
Copy link
Author

DierkDroth commented Jan 2, 2023

@vargaz that's interesting: I can't compile a blank UNO template using your code since there is conflict on static 'Main' function. Even if I stuffed your code in a different namespace would it not compile. @jeromelaban FYI
Not sure why it compiles fine in my app...

So, I renamed 'Main' to 'Run'. However, the AOT compilation of a blank UNO project would not crash.

@DierkDroth
Copy link
Author

@vargaz I attached build logs and a more detailed screenshot

build.zip

image

vargaz added a commit to vargaz/runtime that referenced this issue Jan 6, 2023
…cmod.

The wrappers are not found at runtime in some cases.

Ref: dotnet#79814.
vargaz added a commit that referenced this issue Jan 6, 2023
…cmod. (#80279)

The wrappers are not found at runtime in some cases.

Ref: #79814.
github-actions bot pushed a commit that referenced this issue Jan 22, 2023
…cmod.

The wrappers are not found at runtime in some cases.

Ref: #79814.
@lewing lewing added this to the 7.0.x milestone Jan 22, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 22, 2023
carlossanlop pushed a commit that referenced this issue Feb 8, 2023
…cmod. (#81003)

The wrappers are not found at runtime in some cases.

Ref: #79814.

Co-authored-by: Zoltan Varga <[email protected]>
@lewing lewing closed this as completed May 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Projects
None yet
Development

No branches or pull requests

4 participants