Fix evented exec and long-lived scope waiter retention - #65
Merged
Conversation
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.
What type of PR is this? (check all applicable)
Description
This PR fixes two backend/runtime issues in
lua-fibersand adds regression coverage for both.First, it fixes unbounded memory growth in long-lived scopes caused by cancelled one-shot waiters being left as tombstones. Scope-aware blocking operations race their main operation against the scope cancellation/fault one-shots. When the main op wins, the losing one-shot waiter is cancelled. Previously, cancellation cleared the callback but left the waiter record in the one-shot waiter array. Long-lived scopes performing repeated stream operations could therefore accumulate large numbers of cancelled waiter records. This was visible during repeated upload-shaped stream transfers.
Second, it adds an event-driven luaposix process backend for
LuaJIT + luaposix. The existing SIGCHLD/self-pipe backend remains appropriate for PUC Lua, but LuaJIT is unsafe with a Lua-level SIGCHLD handler in this path. The newposix_reaperbackend keeps the parent scheduler fully evented by using a lightweight reaper process and a sentinel pipe, similar in shape to the existing nixio compromise.Changes included:
Add
exec_backend.posix_reaperforLuaJIT + luaposix.parent -> reaper -> child.Update exec backend selection.
pidfdremains preferred where available.sigchldremains the PUC Lua luaposix backend.posix_reaperis selected for LuaJIT when using the posix family.nixioremains the nixio-family backend.Fix one-shot cancellation retention.
Add backend-family cycling tests.
Runs relevant I/O tests in separate subprocesses for each backend family.
Prevents silent mixed-family fallback.
Covers:
ffifd/poller/exec familyposixfd/poller/exec familynixiofd/poller/exec familyAdd one-shot waiter regression coverage.
Add a small upload-shaped regression test to the standard suite.
Related Issues, Tickets & Documents
No linked issue.
Relevant context:
Screenshots/Recordings
Not applicable. This PR has no visual changes.
Manual test
Manual test description
Manually tested with both LuaJIT and PUC Lua.
Commands run:
cd tests luajit test.lua lua test.luaBoth complete successfully, including:
Added tests?
Added tests:
The upload-shaped test can be controlled with:
Added to documentation?
README changes are not required for the public API surface.