-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
OSX-Arm64 pthread_jit_write_protect_np(bool) does not have a sane initial value #41991
Comments
I think we can handle that ourselves by calling the pthread_jit_write_protect_np in TheUMEntryPrestubWorker or maybe CreateThreadBlockThrow to establish the initial state. |
I don't see how that can happen on the clients new thread which gets a pointer to our managed code.
Unless all delegates get that as a wrapper and the wrapper is not in JIT generated code |
I did wonder if we could hijack the exception and set the JIT write enable state in this case. I suspect we can, but it may introduce unnecessary security risk. A sane default seems safer. |
All the callbacks go through the asm TheUMEntryPrestub that then calls the c++ TheUMEntryPrestubWorker. |
UnmanagedCallersOnly methods don't go through |
Right, I was referring to regular callbacks. |
I didn't find a test which failed due to |
Did you run src\tests\Interop\UnmanagedCallersOnly ? |
I think it was run.... I just reran it now too. Looks like there should be coverage for the new thread case. The entry path is a little different, so perhaps it was getting JIT |
Re-opened based on comments here #40435 (comment) |
Discovered while debugging the
Exceptions/ForeignThread/ForeignThreadExceptions/ForeignThreadExceptions.dll
test.The test creates a new thread which invokes JIT managed code.
runtime/src/tests/Exceptions/ForeignThread/ForeignThreadExceptionsNative.cpp
Lines 49 to 60 in 00d0dba
The new thread is failing when it tries to execute the managed code.
This is apparently occurring because the new thread does not default to
pthread_jit_write_protect_np(true)
.I believe we should try to have Apple set a default which allows new threads to execute JIT code.
/cc @janvorli
The text was updated successfully, but these errors were encountered: