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

Release crash on unmanagedcallersonly framework code #7876

Closed
333fred opened this issue Mar 11, 2023 · 13 comments
Closed

Release crash on unmanagedcallersonly framework code #7876

333fred opened this issue Mar 11, 2023 · 13 comments
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`. need-attention A xamarin-android contributor needs to review

Comments

@333fred
Copy link
Member

333fred commented Mar 11, 2023

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

VS 17.6p1/.NET 8p1

Description

I have a maui app (closed source, unfortunately, but my alias is frsilb if the logs I've attached aren't enough and we need to do more debugging) that uses both EF Core and SignalR. I'm getting a crash in release mode:

Assertion at /__w/1/s/src/mono/mono/metadata/icall.c:6175, condition `!only_unmanaged_callers_only' not met

The crash doesn't happen on every build of the app, but when it does happen, it happens on every launch of that build, and it seems to happen more often than not. I've been unable to minimize it to a single cause yet. No crash occurs when running in debug mode.

Steps to Reproduce

I've attached the logs, let me know if they're not enough to figure it out and we can debug my app. I haven't been able to minimize the crash.

Did you find any workaround?

None.

Relevant log output

Here's the logs with the backtrace.

@333fred 333fred added Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Mar 11, 2023
@333fred
Copy link
Member Author

333fred commented Mar 11, 2023

/cc @MichalPetryka

@grendello
Copy link
Contributor

@333fred @MichalPetryka my first suspicion is, indeed, that there's a mix-up in the packaged assemblies. It is usually caused by something in the obj/ folder getting messed up. Unfortunately, it's impossible to say what's the problem from a runtime crash. We will need a binlog of a build that crashes - please start building with -bl passed to dotnet build (or its equivalent setting in the IDE) and attach the problematic build's one here, once the crash happens. Another thought I had about it is whether your project uses any Android libraries that target classic XA? They don't need to be part of the actual application, just part of the solution. It could potentially cause this kind of problem.

If it is indeed a bin/obj issue, then you'll be able to get to the good state by removing bin and obj, which is a pain, but will get you going until we can pin-point the issue.

@grendello grendello added need-info Issues that need more information from the author. and removed needs-triage Issues that need to be assigned. labels Mar 13, 2023
@ghost
Copy link

ghost commented Mar 13, 2023

Hi @333fred. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@333fred
Copy link
Member Author

333fred commented Mar 13, 2023

If it is indeed a bin/obj issue, then you'll be able to get to the good state by removing bin and obj, which is a pain, but will get you going until we can pin-point the issue.

I suspect this is correct, as I've noticed that doing complete rebuild seems to fix it. I'll grab the binlog from VS tonight.

@ghost ghost added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Mar 13, 2023
@333fred
Copy link
Member Author

333fred commented Mar 14, 2023

Of course when I go to collect logs tonight what was crashing for me nearly every second build last night is doing nothing at all tonight... I'll keep trying to get a log.

@333fred
Copy link
Member Author

333fred commented Mar 15, 2023

Managed to get the logs from a build. It happened after a CTRL+F5 with minor changes (moved a comment around, essentially). As this is not an open source app I'm not going to attach the binlogs here, but will put them on a network share tomorrow for @jonathanpeppers and @dellis1972 to take a look at.

@333fred
Copy link
Member Author

333fred commented Mar 15, 2023

https://microsoft-my.sharepoint.com/:f:/p/frsilb/EuN4UGo4MLBGppt8K1Dn1HYB78DK7cSRA9OdtXMP9wS02A?e=R7d5TP should be accessible to MSFT folks. It has the binlogs from both build and deploy actions in VS, as well as the logcat output from adb shell setprop debug.mono.log default,assembly,mono_log_level=debug,mono_log_mask=all, the built apk, and the zipped bin directory from when it occured.

@Strypper
Copy link

I got this on .NET MAUI 7 when running release any suggestion ?

@333fred
Copy link
Member Author

333fred commented Apr 28, 2023

@Strypper in talking with @jonathanpeppers, a workaround should be putting <AndroidEnableMarshalMethods>false</AndroidEnableMarshalMethods> in your project file. However, if you're seeing this on .NET 7 and not 8, I suspect it may be something different, and the MAUI team might want to take a look at your logs 🙂.

@taublast
Copy link

If it is indeed a bin/obj issue, then you'll be able to get to the good state by removing bin and obj, which is a pain, but will get you going until we can pin-point the issue.

I suspect this is correct, as I've noticed that doing complete rebuild seems to fix it. I'll grab the binlog from VS tonight.

Just happened on Release for me, deleted bin/obj folders for a complete rebuild and the problem was gone. .Net 7.

technobaboo added a commit to technobaboo/stereokit_lynx_dotnet_template that referenced this issue Oct 16, 2023
@mgood7123
Copy link

cleaning does not fix it, as it will reappear sometimes when making seemingly valid changes

@jpobst
Copy link
Contributor

jpobst commented May 17, 2024

Tracking this via #8253.

@jpobst jpobst closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App Runtime Issues in `libmonodroid.so`. need-attention A xamarin-android contributor needs to review
Projects
None yet
Development

No branches or pull requests

9 participants