Skip to content

Commit 3caac43

Browse files
Removed environment variable substitution step from stacktrace
An unintended consequence of attempting to substitute envars in the stacktrace was that subshell literals would be eval- uated as well, which is surprising in that a stacktrace should not be excecuting arbitrary code and incorrect in that any non-reentrant code when executed by the stacktrace would lead to errors elsewhere. Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 8f01725 commit 3caac43

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

hack/lib/log/stacktrace.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ function os::log::stacktrace::print() {
4242
local return_code=$1
4343
local last_command=$2
4444
local errexit_set=${3:-}
45-
set --
46-
47-
# evaulate all of the variables in the last command literal so we have a useful stacktrace
48-
# this will *not* be able to capture positional variables ($1, $@, $*) or variables declared
49-
# in this scope or in the trap handler ($return_code, $last_command, $errexit_set)
50-
# Furthermore, since it is possible that the failure in the last command itself was an unset
51-
# variable, we need to turn off that check to ensure we're not re-triggering it here.
52-
set +o nounset
53-
local -r last_command_with_vars="$( eval "echo \"${last_command}\"" )"
54-
set -o nounset
5545

5646
if [[ "${return_code}" = "0" ]]; then
5747
# we're not supposed to respond when no error has occurred
@@ -82,8 +72,6 @@ function os::log::stacktrace::print() {
8272
if [[ -z "${preamble_finished:-}" ]]; then
8373
preamble_finished=true
8474
os::log::error "PID ${BASHPID:-$$}: ${bash_source}:${BASH_LINENO[$i-1]}: \`${last_command}\` exited with status ${return_code}." >&2
85-
os::log::error "Command with variables substituted is: "
86-
os::log::error $'\t'"${last_command_with_vars}"
8775
os::log::info $'\t\t'"Stack Trace: " >&2
8876
os::log::info $'\t\t'" ${stack_index}: ${bash_source}:${BASH_LINENO[$i-1]}: \`${last_command}\`" >&2
8977
else

0 commit comments

Comments
 (0)