Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: make sure the directory handle is kept alive in rename loop #30

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

cyphar
Copy link
Owner

@cyphar cyphar commented Sep 30, 2024

It turns out the GC can close the directory during our loop in CI sometimes, leading to the following failures (note that dir.Fd() returns -1, which is a closed directory):

  === RUN   TestPartialLookup_RacingRename/openat2=true/swap-dir-danglinglink-basic
  panic: renameat2([-1]"/tmp/TestPartialLookup_RacingRenameopenat2=trueswap-dir-file-basic3291115487/001/tree", "a/b", ..., "file", RENAME_EXCHANGE) = no such file or directory

  goroutine 552 [running]:
  github.com/cyphar/filepath-securejoin.doRenameExchangeLoop(0xc000027680, 0xc0000276e0, 0xc0000025a8, {0x66c786, 0x3}, {0x66c8f4, 0x4})
      /home/runner/work/filepath-securejoin/filepath-securejoin/util_linux_test.go:111 +0x38c
  created by github.com/cyphar/filepath-securejoin.TestPartialLookup_RacingRename.func1.1 in goroutine 551
      /home/runner/work/filepath-securejoin/filepath-securejoin/lookup_linux_test.go:561 +0x525
  exit status 2

Signed-off-by: Aleksa Sarai [email protected]

It turns out the GC can close the directory during our loop in CI
sometimes, leading to the following failures (note that dir.Fd() returns
-1, which is a closed directory):

  === RUN   TestPartialLookup_RacingRename/openat2=true/swap-dir-danglinglink-basic
  panic: renameat2([-1]"/tmp/TestPartialLookup_RacingRenameopenat2=trueswap-dir-file-basic3291115487/001/tree", "a/b", ..., "file", RENAME_EXCHANGE) = no such file or directory

  goroutine 552 [running]:
  github.com/cyphar/filepath-securejoin.doRenameExchangeLoop(0xc000027680, 0xc0000276e0, 0xc0000025a8, {0x66c786, 0x3}, {0x66c8f4, 0x4})
      /home/runner/work/filepath-securejoin/filepath-securejoin/util_linux_test.go:111 +0x38c
  created by github.com/cyphar/filepath-securejoin.TestPartialLookup_RacingRename.func1.1 in goroutine 551
      /home/runner/work/filepath-securejoin/filepath-securejoin/lookup_linux_test.go:561 +0x525
  exit status 2

Signed-off-by: Aleksa Sarai <[email protected]>
@cyphar cyphar merged commit 3bf6419 into main Sep 30, 2024
12 checks passed
@cyphar cyphar deleted the rename-loop-panic branch September 30, 2024 11:38
@cyphar cyphar mentioned this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant