-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native, Mono.Android] GC bridge logging improvements
Context: #9039 While trying to further diagnose #9039, @jonpryor started fearing that a GC bridge issue might be at play, but the current GC bridge logging could use some improvements. Update `OSBridge::take_weak_global_ref_jni()` to do two things: 1. Set the `handle` and `handle_type` fields *before* deleting the original GREF. This is for a hypothetical thread-safety issue wherein the `handle` field and the `Handle` property could return a *deleted* GREF before being updated to the "new" Weak GREF. We have not seen this as being an issue in practice, but it's something we noticed. 2. Update the `from` parameter text to `_monodroid_weak_gref_new()` to look more like a stack trace. Previously, the GREF log would contain entries such as: monodroid-gref: -g- grefc 441 gwrefc 1 handle 0x4fda/G from thread 'finalizer'(17269) monodroid-gref: take_weak_global_ref_jni making me wonder "why is `take_weak_global_ref_jni` there?!" It's there because of the "from" parameter, to provide context. Update it to instead read: monodroid-gref: -g- grefc 441 gwrefc 1 handle 0x4fda/G from thread 'finalizer'(17269) monodroid-gref: at [[gc:take_weak_global_ref_jni]] which makes it clearer what's intended. Update `OSBridge::take_global_ref_jni()` in a similar manner. Update other `_monodroid*_gref_*()` call sites to update *their* `from` parameters accordingly. Update `AndroidRuntime.FinalizePeer()` so that the messages it logs are actually useful. Currently they are: Finalizing handle 0x0/G which leaves a lot to be desired. Update it to instead read: Finalizing Instance.Type=Example.Whatever PeerReference=0x0/G IdentityHashCode=0x123456 Instance=0xdeadbeef "Promote" `LOG_GC` to work in Release builds as well. This means that both: adb shell setprop debug.mono.log gc adb shell setprop debug.mono.gc 1 will work with `libmono-android.release.so`, i.e. Release builds of apps. Update `OSBridge::gc_cross_references()` log the `handle` field of bridged instances.
- Loading branch information
Showing
5 changed files
with
31 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters