Skip to content

Commit

Permalink
[7.0.0] Fix sandbox stashes not being keyed by mnemonic (#20103)
Browse files Browse the repository at this point in the history
Due to a flipped ternary operator, all sandbox directories were stashed
for reuse under the fixed mnemonic `_NoMnemonic_`.

Closes #20067.

Commit
9b91079

PiperOrigin-RevId: 580491602
Change-Id: If8daf935e2aed060a4dd161fe5d1e612a2c2ed4d

Co-authored-by: Fabian Meumertzheim <[email protected]>
  • Loading branch information
bazel-io and fmeum authored Nov 8, 2023
1 parent 33a313c commit 35e5704
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public SymlinkedSandboxedSpawn(
sandboxDebugPath,
statisticsPath,
mnemonic);
this.mnemonic = isNullOrEmpty(mnemonic) ? mnemonic : "_NoMnemonic_";
this.mnemonic = isNullOrEmpty(mnemonic) ? "_NoMnemonic_" : mnemonic;
}

@Override
Expand Down
24 changes: 12 additions & 12 deletions src/test/shell/integration/sandboxing_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -900,17 +900,17 @@ EOF
local sandbox_stash="${output_base}/sandbox_stash"
[[ -d "${sandbox_stash}" ]] \
|| fail "${sandbox_stash} not present"
[[ -d "${sandbox_stash}/_NoMnemonic_/3" ]] \
[[ -d "${sandbox_stash}/Genrule/3" ]] \
|| fail "${sandbox_stash} did not stash anything"
[[ -L "${sandbox_stash}/_NoMnemonic_/3/$execroot_reldir/pkg/a.txt" ]] \
[[ -L "${sandbox_stash}/Genrule/3/$execroot_reldir/pkg/a.txt" ]] \
|| fail "${sandbox_stash} did not have a link to a.txt"

bazel build --reuse_sandbox_directories //pkg:b >"${TEST_log}" 2>&1 \
|| fail "Expected build to succeed"
ls -R "${sandbox_stash}/_NoMnemonic_/"
[[ ! -L "${sandbox_stash}/_NoMnemonic_/6/$execroot_reldir/pkg/a.txt" ]] \
ls -R "${sandbox_stash}/Genrule/"
[[ ! -L "${sandbox_stash}/Genrule/6/$execroot_reldir/pkg/a.txt" ]] \
|| fail "${sandbox_stash} should no longer have a link to a.txt"
[[ -L "${sandbox_stash}/_NoMnemonic_/6/$execroot_reldir/pkg/b.txt" ]] \
[[ -L "${sandbox_stash}/Genrule/6/$execroot_reldir/pkg/b.txt" ]] \
|| fail "${sandbox_stash} should now have a link to b.txt"

bazel clean
Expand Down Expand Up @@ -950,18 +950,18 @@ EOF
local sandbox_stash="${output_base}/sandbox_stash"
[[ -d "${sandbox_stash}" ]] \
|| fail "${sandbox_stash} not present"
[[ -d "${sandbox_stash}/_NoMnemonic_/3" ]] \
[[ -d "${sandbox_stash}/Genrule/3" ]] \
|| fail "${sandbox_stash} did not stash anything"
[[ -L "${sandbox_stash}/_NoMnemonic_/3/$execroot_reldir/pkg/a.txt" ]] \
[[ -L "${sandbox_stash}/Genrule/3/$execroot_reldir/pkg/a.txt" ]] \
|| fail "${sandbox_stash} did not have a link to a.txt"

bazel build --reuse_sandbox_directories --incompatible_sandbox_hermetic_tmp \
//pkg:b >"${TEST_log}" 2>&1 \
|| fail "Expected build to succeed"
ls -R "${sandbox_stash}/_NoMnemonic_/"
[[ ! -L "${sandbox_stash}/_NoMnemonic_/6/$execroot_reldir/pkg/a.txt" ]] \
ls -R "${sandbox_stash}/Genrule/"
[[ ! -L "${sandbox_stash}/Genrule/6/$execroot_reldir/pkg/a.txt" ]] \
|| fail "${sandbox_stash} should no longer have a link to a.txt"
[[ -L "${sandbox_stash}/_NoMnemonic_/6/$execroot_reldir/pkg/b.txt" ]] \
[[ -L "${sandbox_stash}/Genrule/6/$execroot_reldir/pkg/b.txt" ]] \
|| fail "${sandbox_stash} should now have a link to b.txt"

bazel clean
Expand Down Expand Up @@ -992,7 +992,7 @@ EOF
local sandbox_stash="${output_base}/sandbox_stash"
[[ -d "${sandbox_stash}" ]] \
|| fail "${sandbox_stash} not present"
[[ -d "${sandbox_stash}/_NoMnemonic_/3" ]] \
[[ -d "${sandbox_stash}/Genrule/3" ]] \
|| fail "${sandbox_stash} did not stash anything"

bazel clean --reuse_sandbox_directories
Expand All @@ -1002,7 +1002,7 @@ EOF
bazel build --experimental_sandbox_async_tree_delete_idle_threads=2 \
--reuse_sandbox_directories //pkg:a >"${TEST_log}" 2>&1 \
|| fail "Expected build to succeed"
[[ -d "${sandbox_stash}/_NoMnemonic_/6" ]] \
[[ -d "${sandbox_stash}/Genrule/6" ]] \
|| fail "${sandbox_stash} did not stash anything"

bazel clean
Expand Down

0 comments on commit 35e5704

Please sign in to comment.