Skip to content

[LXC] Parallel mount tests can collide on timestamp-based temp directories #1292

Closed

Description

@MGudgin

Relevant area(s)

Windows

Brief description of your issue

The LXC unit test lxc_bindings::tests::a_reused_container_does_not_inherit_an_earlier_runs_mounts can collide with another parallel test because container_with_config derives its temporary directory from only the process ID and SystemTime::now().duration_since(UNIX_EPOCH).as_nanos().

The failure was observed on September 25, 2026 in #1269, workflow run 36185800669, attempt 1, job windows / x64 (108238915286). The failing source was byte-identical between #1269 and its base, and rerunning the failed job succeeded.

Both tests execute in the same test process. If they obtain the same timestamp-derived path, they share <temp>/mxc-lxc-cfg-<pid>-<nanos>/box/config and overwrite each other's managed mount block. In the observed failure, this test expected its first-run /tmp/secret mount but read the neighboring test's /data mount instead.

A robust fix should use collision-resistant, independently owned temporary directories, preferably tempfile::TempDir or an equivalent RAII helper. An atomic per-process suffix would also avoid same-timestamp collisions, but cleanup ownership must remain explicit.

Steps to reproduce

  1. On Windows, run the LXC unit tests with normal parallel test execution:

    cd src
    cargo test -p lxc_common --lib
  2. Repeat under runner load or run the relevant tests concurrently.

  3. Observe whether a_reused_container_does_not_inherit_an_earlier_runs_mounts reads a config written by another test using container_with_config.

Observed CI evidence:

test lxc_bindings::tests::a_reused_container_does_not_inherit_an_earlier_runs_mounts ... FAILED

the first run's mount must be programmed; got:
# Template used to create this container
lxc.include = /usr/share/lxc/config/common.conf
lxc.rootfs.path = dir:/var/lib/lxc/box/rootfs
lxc.mount.entry = /opt/handwritten opt none bind 0 0
# BEGIN MXC managed mounts (rewritten every run)
lxc.mount.entry = /data data none bind,create=dir 0 0
# END MXC managed mounts

Expected behavior

Every test invocation owns a unique temporary LXC directory and config file. Parallel tests cannot observe or overwrite each other's mount entries, and the reuse test deterministically sees /tmp/secret after its first write.

Actual behavior

Two parallel tests can select the same timestamp-derived directory. Their writes race, and the reuse test can observe /data or another neighboring test's content instead of /tmp/secret, causing a nondeterministic assertion failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugSomething is not working as intended.OS-WindowsApplies specifically to Windows hosts or Windows behavior.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions