-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
mono gc not set static field back after object moved when enable interp mode #100065
Comments
@lateralusX @BrzVlad can you help to check these problem? |
This looks like when hot reload is enabled, the roots from the static fields of that class are not being registered at all to the GC. @lambdageek Do you understand what might be going on here ? |
yeah, can you tell me where register static field to roots or scan static field |
runtime/src/mono/mono/metadata/object.c Line 2231 in e12e2fa
mono_gc_alloc_fixed which registers the memory as root, together with a gc descriptor for which slots are to be scanned. During gc, they are then scanned here runtime/src/mono/mono/sgen/sgen-gc.c Line 1288 in e12e2fa
I'm not familiar with the implications of hot reload over these static fields. |
thank you @BrzVlad waiting for @lambdageek for help, or anyone can help me to reproduce it? |
All you do is just enable or disable the hot reload component? You're not actually applying any changes? What happens if you disable hot reload, but set the execution mode to |
yes, I have not apply any change
the problem also exists. |
anyone can take a look at this question |
we have comment out this line
but the alc is not unloading. and the second clue is the FTicker @vargaz can you help me? |
we found that call
|
how can we fixed it, our project is blocking by this problem. |
I have set gc_level=9, because the log file is too big for upload, I paste the log about the in jit mode:
in interp mode:
|
Interesting. So it turns out we actually can allocate static field storage as part of another object when using hot reload. (https://github.com/dotnet/runtime/blob/main/src/mono/mono/component/hot_reload.c#L3092). The interpreter was not aware of this so it doesn't do write barriers when storing to static fields. My understanding is that you still encounter this crash when having hot reload enabled (not just by using mono interpreter) ? If static field storage is part of another object then you are correct that we need write barriers when we store into it. MINT_STSFLD_O and also MINT_STSFLD_VT would need write barriers. For the latter you would need to either pass the field_klass to the opcode so you can use Also, from the debugger screenshot, the bad object 0x1f4f1dee470 has its vtable 0x1f4f309df01. Because the vtable has its least significant bit 1, it is a sign that the value of the vtable is actually the location of the new object. This means that the object from the crash was promoted to location 0x1f4f309df00. You could investigate the type of object if it is something out of the ordinary. In this type of crashes, it would be useful to run with |
thank you, I will continue to try tomorrow. |
when I set
so this set may not useful, and the |
the
|
The logs support the existing theory that the issue is only with storing into static fields. Am I assuming correctly that you didn't tweak
|
this change works, thank you @BrzVlad but but why won't happen when not enable collectiable alc? |
Description
We are embeding mono in UnrealEngine, when we upgrade .ne8.0(v8.0.2), we found sgen-gc will not set static field back after object move when enable hotreloadcomponent.
Reproduction Steps
We have not separate code to reproduct it, but I will describe it as detailed as possible.
we have restore object in static field, when next pass it to internal call the object address after the gc have move it, the value not set back.
I show the code first:
the internal call
the code logic execute as below :
I show the behaviors with hotreload component enable or not.
if we not enable hotreload component, just use jit execute mode, it work correctly:
the first call
AddTicker
, we can checkout theself
object:and we check the
Internal_GetCoreTicker_Cache
static field:the second call the
self
object address have changed:if we enable hotreload component, the static field will not write back:
the first call:
the second call: the self object address have not been changed but the
vtable
is nullExpected behavior
work correctly
Actual behavior
crash
Regression?
.net7.0 work correctly
Known Workarounds
no
Configuration
windows
build v8.0.2 tag
set excute mode
mono_jit_set_aot_mode(MONO_AOT_MODE_INTERP_ONLY);
Other information
No response
The text was updated successfully, but these errors were encountered: