You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Initialize command state before thread creation - #198
When pthread_create fails, createOwnedCommand calls cleanup_function before run_function initializes the signal snapshot pointers. Cleanup frees each pointer and can abort (ios_system.m, the signal snapshot cleanup loop). Zero-initialize functionParameters before it reaches any cleanup path.
The arm64 Simulator regression uses Xcode 27.1 and a Release framework build. It forces one EAGAIN through an external thread-creation interposer with both MallocScribble and MallocPreScribble enabled. Master aborts with status 134; the fix returns 126, preserves the caller's streams and signal handler, and runs the next command with exact NEXT\n output.
An a-Shell build with this change passes normal command, file, pipeline, exit-status and background io.popen checks on an iPhone, with the same results as the unchanged build. The phone run does not inject a thread-creation failure.
I may be missing something obvious, but I'm not seeing what this PR changes in the ios_system.m code. I see just one change where malloc is replaced with calloc(1,...) and two changes in the comments.
You're not missing anything: the fix is that one line. params came from malloc, so its signal snapshot pointers held whatever was in that memory. When pthread_create fails, cleanup_function runs before run_function has set them and frees each one, which aborts (status 134 in the test, with MallocScribble). With calloc they are NULL, so the cleanup is safe and the command returns 126. The two comments said "malloc'ed", which stopped being true. The rest of the PR is the regression test in tests/.
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
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.
When
pthread_createfails,createOwnedCommandcallscleanup_functionbeforerun_functioninitializes the signal snapshot pointers. Cleanup frees each pointer and can abort (ios_system.m, the signal snapshot cleanup loop). Zero-initializefunctionParametersbefore it reaches any cleanup path.The arm64 Simulator regression uses Xcode 27.1 and a Release framework build. It forces one
EAGAINthrough an external thread-creation interposer with bothMallocScribbleandMallocPreScribbleenabled. Master aborts with status 134; the fix returns 126, preserves the caller's streams and signal handler, and runs the next command with exactNEXT\noutput.An a-Shell build with this change passes normal command, file, pipeline, exit-status and background
io.popenchecks on an iPhone, with the same results as the unchanged build. The phone run does not inject a thread-creation failure.