fix(mcp): survive atomic binary replacement#1204
Open
DavidMusk93 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Linux subprocess spawning against atomic replacement of the running binary by preferring a previously saved launch path when it remains executable and refusing to use a deleted /proc/self/exe target before spawning index workers. It also adds a Linux regression test that exercises the “deleted self” scenario by forking, atomically replacing the on-disk executable, and validating that subprocess resolution still uses the saved launch path.
Changes:
- Update
cbm_http_server_resolve_binary_pathto preferg_binary_pathwhen it still points to an executable, and to reject non-executable self paths on Linux. - Add a Linux-only “deleted-self” probe mode to the test runner so a fork/exec’d child can validate resolution behavior after atomic replacement.
- Add a Linux integration regression test covering atomic replacement while the child is running.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_main.c | Adds a Linux-only probe entrypoint used by the new integration test to validate binary-path resolution in a fork/exec child. |
| tests/test_httpd.c | Adds a Linux regression test that forks, atomically replaces the running executable on disk, and asserts resolution prefers the saved launch path. |
| src/ui/http_server.c | Adjusts binary-path resolution to prefer the saved executable path when valid and to avoid returning a deleted /proc/self/exe target as spawnable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+383
to
+385
| ssize_t current_len = readlink("/proc/self/exe", current, sizeof(current) - 1); | ||
| ASSERT_GT(current_len, 0); | ||
| current[current_len] = '\0'; |
DavidMusk93
force-pushed
the
deleted-self-exec-fix
branch
from
July 22, 2026 04:07
e161726 to
9c5e912
Compare
Prefer the saved executable launch path when it still points to an executable, and reject a deleted /proc/self/exe path before spawning index workers. Add a Linux integration regression that forks, atomically replaces the running test binary on disk, and verifies that subprocess resolution uses the saved launch path instead of the now-deleted self path. Signed-off-by: David Musk <davidmusk93@users.noreply.github.com> Signed-off-by: sunmingqiang <sunmingqiang@bytedance.com>
DavidMusk93
force-pushed
the
deleted-self-exec-fix
branch
from
July 22, 2026 04:14
9c5e912 to
f891b2c
Compare
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.
Summary
/proc/self/exepath before spawning index workersTests
build/c/test-runner httpd: 44 passed, 1 Windows-only skipscripts/run-tests-parallel.sh build/c/test-runner 16: 6386 passed, 1 unrelated baseline failure, 1 Windows-only skipThe baseline failure is
tests/test_cli.c:6781(installer must not follow symlinked agent roots outside the selected home). It is unrelated to the three files in this PR and is fixed by a separate local change, intentionally excluded here.Runtime verification
A static build carrying this patch was loaded by both host and container MCP instances. A real
index_repositorycall completed with 17,237 nodes, 99,775 edges,skipped_count=0, andparse_partial_count=0.