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

[coop] make mono_gc_init_finalizer_thread GC Unsafe aware. #19421

Closed
lewurm opened this issue Apr 2, 2020 · 4 comments
Closed

[coop] make mono_gc_init_finalizer_thread GC Unsafe aware. #19421

lewurm opened this issue Apr 2, 2020 · 4 comments
Assignees
Labels
Milestone

Comments

@lewurm
Copy link
Contributor

lewurm commented Apr 2, 2020

Usages in our SDKs:

It would be nice to move those macros into mono_gc_init_finalizer_thread (). However, we aren't sure how much it will break. I'll leave it up to @lambdageek.

/cc @alexischr @akoeplinger

@lewurm lewurm added the task label Apr 2, 2020
@lewurm lewurm added this to the Future milestone Apr 2, 2020
@alexischr
Copy link
Contributor

alexischr commented Apr 2, 2020

To be clear, mono_gc_init_finalizer_thread cannot avoid entering GC-Safe mode - it creates a thread object on the managed heap.

@thaystg Could you discuss the MONO_ENTER_GC_SAFE_UNBALANCED; line in #16907 ? Is it a necessary fix for a certain embedded configuration? If that line is not necessary, we can remove all of this.

@thaystg
Copy link
Contributor

thaystg commented Apr 2, 2020

OKay, the reason why I changed this is because sometimes with embedded mono we can call mono_jit_init_version or mono_jit_init and doesn't start the execution of a managed code yet, and then we try to suspend the vm to run the GC, in this case we got a hang.
To fix this what I tried to do is, enable MONO_ENTER_GC_SAFE_UNBALANCED when it runs mono_jit_init, so we don't need to care about this thread because it's not executing a managed code, until we run mono_runtime_invoke or mono_runtime_invoke that will run a MONO_ENTER_GC_UNSAFE_BALANCED and then it will be needed to stop when we run the GC.

@thaystg
Copy link
Contributor

thaystg commented Apr 2, 2020

I think that we can move the MONO_ENTER_GC_UNSAFE and MONO_EXIT_GC_UNSAFE inside the mono_gc_init_finalizer_thread, mono_gc_init_finalizer_thread is an external only function and will be the same behavior that is already implemented by mono_runtime_invoke because both of them will call managed code.

akoeplinger added a commit that referenced this issue Apr 3, 2020
MONO_ENTER_GC_UNSAFE/MONO_EXIT_GC_UNSAFE aren't in a public header yet: #19421
@lambdageek
Copy link
Member

Fixed by dotnet/runtime#48465

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants