Repository navigation
Fix two bugs: threads not sharing chdir, and a --dir of a single file - #363
Merged
Merged
Conversation
…TCONN
A datagram conversation has no host socket until it binds to a port,
connects, or sends. Until then ipready answered with the default (ready
to read and write) and recvfrom with ENOTCONN, so a poll on a fresh UDP
socket said it was readable and the read failed. Erlang's resolver
polls its new UDP socket and logged the ENOTCONN as an error
({udp_error, Port, enotconn}) during Mix's Hex fetches. Now it's
writable only and a nonblocking recv is EAGAIN, as on Linux, and
creating the host socket kicks the watchers, so a recv blocked before
the socket existed wakes for the reply to its first sendto.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
… a rearm isn't missed An epoll_ctl in another thread changes the interest list and then moves the readiness generation (pollWake). epoll_wait copied the list and only then took the generation, from its first poll, so an EPOLL_CTL_MOD that rearmed an EPOLLONESHOT entry between the two was counted in the generation the wait slept on while the copy still had the entry disarmed: the wait slept with the fd ready until something else woke it. Erlang's poll thread waits that way while its schedulers rearm each socket after a read, so a TLS download stopped partway and Mix's Hex fetches timed out after 60 seconds, in about one run in three. The generation is now taken before the copy. The new epoll_rearm case reads loopback connections a segment at a time, rearming after each, and failed 3 of 3 runs before (a connection readable with no event) and passes 3 of 3 after. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
Linux's threads share the working directory (CLONE_FS), and each of h9's threads is its own kernel process with its own dot, so a chdir in one thread left the others where they were. Erlang's file server changes directory in one thread and Mix compiles relative paths in another, so building elixir-plug/plug failed: could not read file "lib/mime/application.ex". The group now holds a clone of the directory a member last changed to, with a generation, and a member whose generation is behind takes it at the top of its next call. A process with one thread shares nothing; a thread starts in its creator's directory. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
Owner
Author
|
Test results on 082f076 (the merge commit above it changes nothing), in a cloud container on the sud engine:
Still unchecked: KVM, HVF, and WHP, the 9front cases, and plug's full Generated by Claude Code |
A --dir whose host path is a file landed on a stack member as a directory attach and failed with "not a directory". Now the bind goes over the file's path on the stack, making the path (and its parents) when it's missing, and rw writes reach the host file while the rest of the stack keeps its overlay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA
Owner
Author
|
Test results at 2a3dc37 (adds the single-file
Generated by Claude Code |
This was referenced Nov 28, 2026
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.
Requested by Jeff · project thread
Two bug fixes found running real programs through h9x. Bug fixes, so no proposal. Each is its own commit.
Threads share the working directory
Found running
elixir-plug/plugthrough h9x, once #361 let Mix fetch Hex.On Linux, a process's threads share their working directory (
CLONE_FS). In h9, each thread is its own kernel process with its own dot, so achdirin one thread left the others where they were. Erlang's file server changes directory in one thread, and Mix compiles relative paths in another, so plug's deps step failed withcould not read file "lib/mime/application.ex".The thread group now holds a clone of the directory a member last changed to, with a generation number. A member whose generation is behind takes that directory at the top of its next call (
syncDotindispatch). A process with only one thread shares nothing, and a new thread starts in its creator's directory. The kernel side gainsh9_linux_dotget,h9_linux_dotset, andh9_linux_chanref.New
[linux-threads]casecwd_threads: a thread'schdirmoves the main thread, the main thread'schdirmoves a later thread, and a thread'sfchdirmoves the main thread.spec/abi-linux.md's thread paragraph now says the group holds the working directory.The go-stdtest thread had the same fix for Go's
TestProgWideChdirand is dropping its copy in favor of this one.A
--dirof one fileA
--dirwhose host path is a file, such as--dir app.conf:#L/etc/app.conf:ro, became a directory attach on the stack member and failed withnot a directory.Now
resolveMountmarks a--dirwhose host path is a file, and the machine binds such a mount over the file's path on the stack after the stack is built, making the path and its parents when they're missing. A target that is a directory is refused. A file mount doesn't make the stack's member writable, sorwwrites reach the host file while every other write still goes to the overlay.spec/cli.md's--dirrow describes this.New
[mounts]test: a read-only file at a new, deep path, and a read-write file whose append reaches the host, with a write to the read-only one refused.The branch merges its own already-merged #361 commits so that the push needed no force. Only the files above differ from main.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LLcnT1EGgD3xQKfCsAjjvA