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

Assertion at /__w/1/s/src/mono/mono/metadata/loader.c:1638, condition `id <= GPOINTER_TO_UINT (*data)' not met #93687

Closed
crui3er opened this issue Oct 18, 2023 · 9 comments · Fixed by #99617
Labels
area-Tracing-mono in-pr There is an active PR which will close this issue when it is merged needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration

Comments

@crui3er
Copy link

crui3er commented Oct 18, 2023

Description

I am profiling a hybrid blazor app on Android.
I follow to instuction https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/tracing.md
If I move app to background and then bring it back, then stopping trace recording fails with an error below, app crashes.

[00:00:00:46]   Recording trace 1,3945   (MB)
Press <Enter> or <Ctrl+C> to exit...
[ERROR] Microsoft.Diagnostics.NETCore.Client.ServerNotAvailableException: Could not send Stop command. The target process may have exited.
   at Microsoft.Diagnostics.NETCore.Client.EventPipeSession.Stop() in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/EventPipeSession.cs:line 61
   at Microsoft.Diagnostics.Tools.Trace.CollectCommandHandler.Collect(CancellationToken ct, IConsole console, Int32 processId, FileInfo output, UInt32 buffersize, String providers, String profile, TraceFileFormat format, TimeSpan duration, String clrevents, String clreventlevel, String name, String diagnosticPort, Boolean showchildio, Boolean resumeRuntime) in /_/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs:line 321

In android log I found an error with failed assertion (see title) that causes app crash.
In past (I used .net 7.0.0 workload) I had similar issue sometimes during recording startup traces, but i could workaround it with doing an extra attemt. But moving app to background and back to foreground make it crash every time.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.1.9171

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

10-18 21:46:31.142	Xiaomi Redmi Note 9 Pro	Error	15057	.actual.dev.ap	* Assertion at /__w/1/s/src/mono/mono/metadata/loader.c:1638, condition `id <= GPOINTER_TO_UINT (*data)' not met
10-18 21:46:31.547	Xiaomi Redmi Note 9 Pro	Error	15057	libc	Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 15079 (Thread-2), pid 15057 (.actual.dev.app)
@PureWeen
Copy link
Member

@jonathanpeppers thoughts?

@jonathanpeppers
Copy link
Member

  • Assertion at /__w/1/s/src/mono/mono/metadata/loader.c:1638, condition `id <= GPOINTER_TO_UINT (*data)' not met

Seems like the assertion is here (looking at release/7.0 branch):

g_assert (id <= GPOINTER_TO_UINT (*data));

I think we can move to dotnet/runtime.

@jonathanpeppers jonathanpeppers transferred this issue from dotnet/maui Oct 18, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 18, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 18, 2023
@danmoseley danmoseley removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 18, 2023
@crui3er
Copy link
Author

crui3er commented Nov 15, 2023

Hi. Any chance somebody can help with this?

@tommcdon
Copy link
Member

Adding @davmason @mdh1418 for thoughts
cc @lateralusX

@lateralusX
Copy link
Member

Probably need local repro or callstack from the assert since its in a generic loader method, not directly called by EventPipe, having that said, EventPipe iterates through types when emitting rundown events, so if anything has been released/unloaded as part of moving app to background and then to foreground without being fully reflected in JIT or interpreter tables, that could cause side effects. We also have a fix for a rare race condition in the JIT table currently in main, that table gets enumerated by EventPipe during shutdown, so if there are other activities triggered in the app that cause a lot of traffic on the JIT table while we iterate it (ending up growing it) we could hit issues trying to get additional metadata about a type in the table, #96771. This is a rare race condition that I personally have not seen it (either live or on CI) so it shouldn't be that common, but just wanted to mention it since it happens during rundown and if it does happen will cause issues around the method/type handling.

@mdh1418
Copy link
Member

mdh1418 commented Feb 12, 2024

I just traced a default maui app (built with dotnet 8.0.300-preview.24107.20) on both Android emulator and Android device with dotnet-dsrouter and dotnet-trace version 8.0.510801. I didn't hit any crashes when moving that app to background and bringing it back to foreground.

@crui3er would you happen to have a sample app that reproduces the issue that you wouldn't mind sharing, since it doesn't seem to be occurring in a default scenario?

edit: Also tried tracing the default maui-blazor app on android device

@mdh1418 mdh1418 added the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 14, 2024
@ghost
Copy link

ghost commented Feb 14, 2024

This issue has been marked needs-author-action and may be missing some important information.

@mdh1418 mdh1418 removed the untriaged New issue has not been triaged by the area owner label Feb 14, 2024
@crui3er
Copy link
Author

crui3er commented Feb 18, 2024

I can't provide sample project. Template maui app did cause this issue. But our app is quite big and I can't figure out when this issue appeared.
My last test showed that I can successfully collect a trace. May be updating tools or sdk helped with it.
dotnet-dsrouter 8.0.510501
dotnet-trace 8.0.510501
android (workload) 34.0.52/8.0.100
But for android we currently stick to runtime 8.0.0 since there is regression in 8.0.1 preventing debugging #96804 (comment)

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Feb 18, 2024
@mdh1418
Copy link
Member

mdh1418 commented Feb 20, 2024

Thank you for checking that the tools work for your workflow now! It seems like that issue is fixed, and it looks like dotnet sdk 8.0.200 is out now https://dotnet.microsoft.com/en-us/download/dotnet if you wanted to try that out.

I'll close this issue as it may have been fixed, and if we see the issue pop up again we can reopen this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Tracing-mono in-pr There is an active PR which will close this issue when it is merged needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants