Problem
The scratch paths are
${TMPDIR:-/tmp}/bashunit/run/<os>/<random token>
${TMPDIR:-/tmp}/bashunit/parallel/<os>/<random token>
and both cleanups guard with a substring match:
case"$target"in*/bashunit/run/*)
rm -rf "$target"
/tmp/bashunit/run/Linux — the per-OS parent, shared by every concurrent
run — satisfies that pattern. So does /tmp/bashunit/run/Linux/.
If the random token is ever empty, _BASHUNIT_RUN_OUTPUT_DIR resolves to that
parent and the run's own cleanup deletes every other run's scratch directory
on the machine. The token comes from $(bashunit::random_str 8); a command
substitution that fails under load yields an empty string, which is exactly the
condition where several runs are in flight.
I have not proven this happens in the wild — it is reachable, not observed. But
a cleanup that can widen from "my directory" to "everyone's" on an empty
variable is worth closing on its own.
Fix
Require the token segment (*/bashunit/run/*/?*) and strip a trailing slash
first, so an empty token falls through to the existing refusal instead of
matching via the parent. Same for the parallel tree.
Related
Not claimed as the cause of #1137, though it would fit the symptom there: a
scratch directory vanishing mid-run while nothing in src/ appears to delete
it.
Problem
The scratch paths are
and both cleanups guard with a substring match:
/tmp/bashunit/run/Linux— the per-OS parent, shared by every concurrentrun — satisfies that pattern. So does
/tmp/bashunit/run/Linux/.If the random token is ever empty,
_BASHUNIT_RUN_OUTPUT_DIRresolves to thatparent and the run's own cleanup deletes every other run's scratch directory
on the machine. The token comes from
$(bashunit::random_str 8); a commandsubstitution that fails under load yields an empty string, which is exactly the
condition where several runs are in flight.
I have not proven this happens in the wild — it is reachable, not observed. But
a cleanup that can widen from "my directory" to "everyone's" on an empty
variable is worth closing on its own.
Fix
Require the token segment (
*/bashunit/run/*/?*) and strip a trailing slashfirst, so an empty token falls through to the existing refusal instead of
matching via the parent. Same for the parallel tree.
Related
Not claimed as the cause of #1137, though it would fit the symptom there: a
scratch directory vanishing mid-run while nothing in
src/appears to deleteit.