-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make vm_interrupt and timed_out atomic #7937
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
Conversation
03064b1
to
ae1bf94
Compare
The largest issue here is that the The second is that there is no ABI guarantee in the standard that Here are two options I can think of to fix this:
Honestly, the latter sounds like a better option to me. Thoughts? Rough API, inspired by the C atomics APIs but without user-provided memory orderings (would use bool zend_vm_interrupt_compare_exchange(zend_executor_globals *, bool *expected, bool desired);
bool zend_vm_interrupt_exchange(zend_executor_globals *, bool desired);
bool zend_vm_interrupt_load(const zend_executor_globals *);
bool zend_vm_interrupt_store(zend_executor_globals *, bool desired); I'm not sure about using |
Nikita suggested I look into using only atomic operations, not an atomic type, to see how that goes. I'll try that the next time I get a moment to work on it. |
c2f9d4f
to
e6a6ac9
Compare
This is done by adding a new zend_atomic_bool type. The type definition is only available for compiler alignment and size info; it should be treated as opaque and only the zend_atomic_bool_* family of functions should be used. Note that directly using atomic_bool is complicated. All C++ compilers stdlibs that I checked typedef atomic_bool to std::atomic<bool>, which can't be used in an extern "C" section, and there's at least one usage of this in core, and probably more outside of it. So, instead check that atomic_bool has the same size and alignment as native bool and if so we'll cast it.
e6a6ac9
to
54c37e8
Compare
Closing in favor of a fresh PR. |
For future reference, the fresh PR is at #8327 |
On Windows these are already set from another thread and should be
atomic. On Linux it is unclear to me if this should be done based on
the existing code.
However, extensions which use vm interrupts are very likely to do the
same thing that Windows is doing: set a vm_interrupt from another
thread.
This combination suggests to me that this change is overdue.
This change is pretty trivial: I expect any issues to arise from from build
system changes or adding compiler flags, etc.