Skip to content

Fix exec of script when script launched by name#96

Merged
mplegendre merged 1 commit into
llnl:develfrom
ParaToolsInc:script-path-fix
Sep 4, 2025
Merged

Fix exec of script when script launched by name#96
mplegendre merged 1 commit into
llnl:develfrom
ParaToolsInc:script-path-fix

Conversation

@nchaimov
Copy link
Copy Markdown
Collaborator

Fixes a bug in Spindle found in the tau-cuda test of the E4S testsuite. When a script is executed, the kernel implementation replaces the original argv[0] with a string that is the absolute path to the script if argv[0] was not already a path. Thus, a case like:

export PATH="$PWD/interpreter_test_dir:$PATH"
interpreter_test_perl

where interpreter_test_perl is in interpreter_test_dir would fail with Spindle because the argument to the interpreter would be interpreter_test_perl rather than the path, so that the interpreter could not find the input script.

Fixed by mimicking kernel behavior: if already a path, use original argv[0] as is; otherwise substitute with the absolute path.

Also adds a test which fails without this fix:

Running: ./run_driver --serial ./interpreter_test
Can't open perl script "interpreter_test_perl": No such file or directory
FAILED.
SOME TESTS FAILED

and which passes with the fix:

Running: ./run_driver --serial ./interpreter_test
PASSED.
ALL TESTS PASSED

I have rerun the E4S testsuite and verified that this both fixes the tau-cuda test failure and does not introduce any new failures.

When a script is launched by name, to be found in $PATH, the kernel
implementation of exec substitutes the absolute path to the script as
the argument to the interpreter, but Spindle did not replicate this
behavior, leaving argv[0] as is. This is fixed by replacing argv[0] with
orig_path if argv[0] is not a path. Adds test to verify fix.
@mplegendre mplegendre merged commit 0aa95ce into llnl:devel Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants