ci: disable opcache.protect_memory for phpt suite — incompatible with threaded workers (#93)#108
Merged
Merged
Conversation
…ith threaded workers) (#93) opcache.protect_memory=1 (a run-tests default) guards the SHM with process-global mprotect toggled OUTSIDE the compile lock. The true-async worker pool runs workers as threads in one address space, so one worker's SHM_PROTECT flips the page read-only under another worker's in-flight SHM write during concurrent compilation on pool rotation — an intermittent SIGBUS (seen as the 053 flake on macOS ARM64). opcache itself notes "mprotect() is process-global and races" (ZendAccelerator.c). Not a production concern: the directive defaults off and the actual compilation is serialized by zend_shared_alloc_lock; only a benign last_used timestamp write is left unlocked. Override it to 0 in every phpt run.
Contributor
CoverageTotal lines: 75.45% → 75.44% (-0.01 pp)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause of the
053-hot-reload-watchermacOS flakeopcache.protect_memory=1(a run-tests default) protects the opcache SHM with process-globalmprotect, toggled viaSHM_UNPROTECT/SHM_PROTECToutside the compile lock (persistent_compile_file,ZendAccelerator.c).The true-async worker pool runs workers as threads in one address space. On hot-reload rotation, fresh workers concurrently recompile the changed file into the shared SHM. One worker's
SHM_PROTECTflips the page read-only process-wide while another worker is mid-write → SIGBUS (KERN_PROTECTION_FAILURE). Backtrace (captured via the new crash-report CI step):opcache itself acknowledges this: "mprotect() is process-global and races" (
ZendAccelerator.c).Why this is safe
opcache.protect_memorydefaults to0; thenSHM_(UN)PROTECTare no-ops.zend_shared_alloc_lock(atsrm_mutex_lockunder ZTS), so no SHM corruption.last_usedtimestamp — a benign torn write.So
protect_memory=1is a debug/CI diagnostic that is architecturally incompatible with the threaded-worker model; it produces false crashes, not real ones.Change
Pass
-d opcache.protect_memory=0to every phpt run (linux, macos, windows, debug-macos-workers, chaos). Verified locally that run-tests appends the user-dafter its hardcodedprotect_memory=1, so the last one wins → child gets0.