Skip to content

Conversation

@monojenkins
Copy link
Contributor

@monojenkins monojenkins commented Sep 25, 2020

!! This PR is a copy of mono/mono#20435, please do not edit or review it in this repo !!
Do not automatically approve this PR:

* Consider how the changes affect configurations in this repo,
* Check effects on files that are not mirrored,
* Identify test cases that may be needed in this repo.

!! Merge the PR only after the original PR is merged !!




Addresses mono/mono#20290 and mono/mono#20283

If a foreign thread (that was created outside the runtime) calls
mono_thread_detach, leave it in a preemptively-suspendable state, since we can't expect it to coop suspend.

Conversely in mono_thread_attach (external only), ensure that we always leave
the thread in GC Unsafe (aka RUNNING) state, for cases like

while (cond) {
  t = mono_thread_attach (domain);
  <...>
  mono_thread_detach (t);
}

To make this work, we also make mono_thread_detach and mono_thread_attach external only. The runtime should use mono_thread_internal_detach and mono_thread_internal_attach.

@lambdageek
Copy link
Member

@lateralusX I pushed f6e9c01 into this PR to add a call in EventPipe to mono_thread_internal_attach (MONO_PROFILER_API) instead of mono_thread_attach (MONO_API) - I think this means I need to fix the non-static EP build by adding an implementation using the function table, right?

@lateralusX
Copy link
Member

@lambdageek don't worry about that at the moment, as part of #41872 I pushed these methods into support methods that are already hooked up to the function table, so depending on what PR that get merged first we just need to adjust call within that function, eventpipe_thread_attach.

Addresses mono/mono#20290 and mono/mono#20283

If a foreign thread (that was created outside the runtime) calls
`mono_thread_detach`, leave it in a preemptively-suspendable state, since we can't expect it to coop suspend.

Conversely in `mono_thread_attach` (external only), ensure that we always leave
the thread in GC Unsafe (aka RUNNING) state, for cases like

    while (cond) {
      t = mono_thread_attach (domain);
      <...>
      mono_thread_detach (t);
    }

---

To make this work, we also make `mono_thread_detach` and `mono_thread_attach` external only.  The runtime should use `mono_thread_internal_detach` and `mono_thread_internal_attach`.
@monojenkins monojenkins force-pushed the sync-pr-20435-from-mono branch from d071f85 to a4f30d5 Compare October 6, 2020 20:16
@lambdageek
Copy link
Member

The (Libraries Test Run release mono Linux x64 Debug) failure in SetDateTimeMax is due to #43166

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants