binpash / binpash/hs

Shell built-ins fail to run with the new tracer

Open
#75 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Shell
Stars
19
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Shell built-ins cannot be traced by `strace`.

This also raises a question about what commands should be speculated or not. Currently, we try to speculate everything except for some hard-coded built-ins (*unsafe nodes*) (i.e., `break,` `continue`). To resolve these, we stop any further speculation, run the node on the system's shell, and restart everything that is after the *unsafe* node

Current speculation is that we can be sound by:
1. resolving aliases and expanding fully
2. checking if the command is a special builtin (in a hardcoded list for bash special builtins)
3. checking that it is not a function
4. checking if the command is in the utility hardcoded list (including cd etc)

Regarding (4):

Some **special** built-ins that we can rule out without any further checks include the following (these should probably be treated as unsafe):

`break`, `colon`, `continue`, `dot`, `eval`, `exec`, `exit`, `export`, `readonly`, `return`, `set`, `shift`, `times`, `trap`, `unset`.

Some **non-special** built-ins that we can rule out without any further checks include the following (most of these won't break `strace`, with some exceptions -- *special-utilities*):
`alias`, `bg`, `cd`, `command`, `fg`, `hash`, `jobs`, `local`, `pushd`, `popd`, `umask`, `type`, and, depending on the shell, `echo`, `kill`, `printf`, `pwd`.

More details [here](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01).

We can define the built-in list for each shell on setup maybe by running `type` on the setup of `hs,` not while speculating, for overhead reasons. We could instead see an `strace` path failure and then use `type` to confirm it's builtin and then remember that for the rest of the run (i.e., add it to BASH_PRIMITIVES)

It might also make sense to keep track of the uses of `alias` and `unalias` in the system. For this, as we're running, we should observe any use of `alias` or `unalias`. hand that off directly to the shell and call `setalias` on the parser library.

See [analysis.py](https://github.com/binpash/dynamic-parallelizer/blob/main/parallel-orch/analysis.py).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.