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

[jni] Refresh current domain after attaching thread to runtime when registering types. #228

Merged
merged 1 commit into from
Sep 19, 2016

Conversation

garuma
Copy link
Contributor

@garuma garuma commented Sep 19, 2016

Change triggered by https://bugzilla.xamarin.com/show_bug.cgi?id=44448

It's possible for the register call to be called on a thread that hasn't been registered with Mono yet. As such, the mono_domain_get call will return NULL until mono_jit_thread_attach is invoked where domain information for the current thread becomes correct.

This is an issue because it means we invoke monodroid_runtime_invoke passing NULL as a bogus domain argument. This caused a crash with mono_domain_set as it doesn't support being passed a NULL domain.

This commit solves the problem by re-requesting the current domain after the mono_jit_thread_attach call. If the thread had been registered beforehand, this will essentially be a no-op as it should return the same domain again. If it hadn't, attaching the thread will have set the current domain to be the root appdomain which will be returned by mono_domain_get making our current domain variable now valid.

…egistering types.

Change triggered by https://bugzilla.xamarin.com/show_bug.cgi?id=44448

It's possible for the register call to be called on a thread that hasn't been registered with Mono
yet. As such, the `mono_domain_get` call will return NULL until `mono_jit_thread_attach` is invoked where
domain information for the current thread becomes correct.

This is an issue because it means we invoke `monodroid_runtime_invoke` passing NULL as a bogus domain
argument. This caused a crash with `mono_domain_set` as it doesn't support being passed a NULL domain.

This commit solves the problem by re-requesting the current domain after the `mono_jit_thread_attach`
call. If the thread had been registered beforehand, this will essentially be a no-op as it should return
the same domain again. If it hadn't, attaching the thread will have set the current domain to be the
root appdomain which will be returned by `mono_domain_get` making our current domain variable now valid.
@jonpryor jonpryor merged commit 7f9a114 into master Sep 19, 2016
jonpryor pushed a commit that referenced this pull request Sep 20, 2016
…egistering types. (#228)

Change triggered by https://bugzilla.xamarin.com/show_bug.cgi?id=44448

It's possible for the register call to be called on a thread that hasn't been registered with Mono
yet. As such, the `mono_domain_get` call will return NULL until `mono_jit_thread_attach` is invoked where
domain information for the current thread becomes correct.

This is an issue because it means we invoke `monodroid_runtime_invoke` passing NULL as a bogus domain
argument. This caused a crash with `mono_domain_set` as it doesn't support being passed a NULL domain.

This commit solves the problem by re-requesting the current domain after the `mono_jit_thread_attach`
call. If the thread had been registered beforehand, this will essentially be a no-op as it should return
the same domain again. If it hadn't, attaching the thread will have set the current domain to be the
root appdomain which will be returned by `mono_domain_get` making our current domain variable now valid.
jonpryor pushed a commit that referenced this pull request Sep 20, 2016
…egistering types. (#228)

Change triggered by https://bugzilla.xamarin.com/show_bug.cgi?id=44448

It's possible for the register call to be called on a thread that hasn't been registered with Mono
yet. As such, the `mono_domain_get` call will return NULL until `mono_jit_thread_attach` is invoked where
domain information for the current thread becomes correct.

This is an issue because it means we invoke `monodroid_runtime_invoke` passing NULL as a bogus domain
argument. This caused a crash with `mono_domain_set` as it doesn't support being passed a NULL domain.

This commit solves the problem by re-requesting the current domain after the `mono_jit_thread_attach`
call. If the thread had been registered beforehand, this will essentially be a no-op as it should return
the same domain again. If it hadn't, attaching the thread will have set the current domain to be the
root appdomain which will be returned by `mono_domain_get` making our current domain variable now valid.
radical pushed a commit that referenced this pull request May 8, 2018
Added Gendarme Configuration, to build `Java.Interop.dll` with mcs
compiler in a separate output directory `bin/GendarmeDebug`.

Updated `fxcop` rule in `Makefile` to let gendarme use mcs compiled
version with `.mdb` symbols file to have source file line information
again.
@jpobst jpobst deleted the libmonodroid-update-domain branch March 8, 2021 17:02
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants