Fix execl/execle/execlp varargs argument corruption#3582
Merged
ptitSeb merged 1 commit intoptitSeb:mainfrom Feb 28, 2026
Merged
Fix execl/execle/execlp varargs argument corruption#3582ptitSeb merged 1 commit intoptitSeb:mainfrom
ptitSeb merged 1 commit intoptitSeb:mainfrom
Conversation
The argument-filling loop in my_execl(), my_execle(), and my_execlp() used getVargN(emu, cnt+1) which always reads the last vararg before NULL. This meant every argv entry was filled with the same (wrong) value, corrupting the argument list passed to execv/execve/execvp. Fix by using getVargN(emu, i+1) to read each argument in order. This caused x64 applications that use execl() to re-exec themselves (e.g. game restart via fork+execl) to fail with missing binary path. Fixes ptitSeb#3542 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Fixes a bug where
my_execl(),my_execle(), andmy_execlp()always read the last vararg instead of each argument in sequence.The argument-filling loop used
getVargN(emu, cnt+1)(constant index — always the last arg before NULL) instead ofgetVargN(emu, i+1)(incrementing index — each arg in order). This corrupted theargvarray passed toexecv/execve/execvp.Before (broken):
After (fixed):
For example,
execl("./game", "-fullscreen", "-nosound", NULL)would produceargv = [NULL, NULL](reading past the args) instead ofargv = ["-fullscreen", "-nosound"].Fixes #3542
Test plan
execl()to re-exec itself🤖 Generated with Claude Code