Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Implement runtime suspension for OSX #1610

Merged
merged 1 commit into from
Sep 23, 2015

Conversation

janvorli
Copy link
Member

This change implements runtime suspension for OSX using activation
injection, the same mechanism as Linux uses.
I have modified the activation injection mechanism by adding a new
function that CoreCLR registers with PAL and PAL calls it to check
if an instruction address is safe for injection. The injection is
performed only if this new function returns true.
The activation on OSX is performed by suspending the target thread,
checking the instruction address in the suspended thread's context
using the above mentioned function and modifying the context to
perform the injection only at injection safe place.

As an additional detail, I have fixed the #1594, since it was similar to the activation handler wrapper creation.

@janvorli
Copy link
Member Author

@jkotas, @kangaroo Can you take a look please?

@@ -314,6 +314,10 @@ namespace CorUnix
DWORD m_dwLwpId;
pthread_t m_pthreadSelf;

#if HAVE_MACH_THREADS
mach_port_t m_machPortSelf;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this being cleaned up when the thread dies, which means we'll leak the port.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it needs a cleanup? I was under an impression that the pthread_mach_thread_np just exposes mach port that is stored in the pthread_t and is bound to it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct, I just checked and it isn't cloned or ref'd so this should be ok.

@janvorli
Copy link
Member Author

cc: @sergiy-k

@sergiy-k
Copy link

LGTM

This change implements runtime suspension for OSX using activation
injection, the same mechanism as Linux uses.
I have modified the activation injection mechanism by adding a new
function that CoreCLR registers with PAL and PAL calls it to check
if an instruction address is safe for injection. The injection is
performed only if this new function returns true.
The activation on OSX is performed by suspending the target thread,
checking the instruction address in the suspended thread's context
using the above mentioned function and modifying the context to
perform the injection only at injection safe place.
@janvorli janvorli force-pushed the osx-thread-suspension-activation-2 branch from 867ca0c to 0f6c0c3 Compare September 23, 2015 19:25
@jkotas
Copy link
Member

jkotas commented Sep 23, 2015

LGTM

janvorli added a commit that referenced this pull request Sep 23, 2015
…on-2

Implement runtime suspension for OSX
@janvorli janvorli merged commit a2491e3 into dotnet:master Sep 23, 2015
@janvorli janvorli deleted the osx-thread-suspension-activation-2 branch September 23, 2015 22:18
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…nsion-activation-2

Implement runtime suspension for OSX

Commit migrated from dotnet/coreclr@a2491e3
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.

6 participants