Kompile executes post-processing command in modified environment

Open
#2,974 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
docker, shell

Research direction

Start at the kompile entry point handling --post-process and reproduce the behavior with script.sh in the Docker command shown. Compare the environment seen by script.sh when run directly and through kompile; done means post-processing preserves the caller's environment without unintended PATH changes.

Written by the indexing model from the issue text.

Description

When running kompile with --post-process <command>, one would expect that command is executed in the caller's environment (extended perhaps with a few variables that do not clash with existing ones).

This is not the case however. Consider e.g. script.sh:

env
false

Then

% docker run -it --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u):$(id -g) runtimeverificationinc/kframework-k:ubuntu-focal-5.4.26 sh script.sh

produces

HOSTNAME=11b5112cca9a
HOME=/
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=<working directory>
TZ=America/Chicago

whereas

% docker run -it --rm -v $(pwd):$(pwd) -w $(pwd) -u $(id -u):$(id -g) runtimeverificationinc/kframework-k:ubuntu-focal-5.4.26 kompile imp.k --post-process 'sh script.sh'

produces

[Error] Critical: Post-processing returned a non-zero exit code: 1
Stdout:
K_COLOR_SUPPORT=8
HOSTNAME=16538a1e94af
LD_LIBRARY_PATH=:/usr/lib/kframework/native/linux64
SHLVL=1
HOME=/
_=/usr/lib/kframework/../../bin/java
TERM=xterm
K_OPTS=-Xms64m -Xmx4096m -Xss32m -XX:+TieredCompilation
PATH=/usr/lib/kframework/native/linux64:/usr/lib/kframework/../../bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LC_ALL=C
PWD=<working directory>
TZ=America/Chicago

Stderr:

Notably, $PATH is extended with new directories, so command names might resolve to different files.

Dominant language
Python
Stars
591
Forks
163
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from runtimeverification/k

All issues in runtimeverification/k

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.