-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: RemoveAll blocks indefinitely on large directories without permissions #29921
Comments
Seems closely related to #20841, fixed in Go 1.11. |
I just built the 1.11.5 from source and, although the RemoveAll code has changed, the same behavior is still present. Is there a target branch you would like me to confirm this behavior for? |
You could try 1.12beta2, though I don't expect it to be fixed. I only meant to point out the related issue. |
Here is a patch of 1.12beta2 that solves this problem. Hopefully this will more clearly illustrate the error conditions.
I'm not proposing this as a solution (it may create other cases I'm not familiar with), and there is still a similar logic error for the noat RemoveAll implementation. |
I'd bet that fix is what caused this issue :-) |
must be:
to reproduce the issue, otherwise you can still remove the parent. |
I have the same problem. |
Change https://golang.org/cl/171099 mentions this issue: |
Change https://golang.org/cl/203502 mentions this issue: |
…ReqSize Previously we injected an error, and the injection points were (empirically) not realistic on some platforms. Instead, we now make the directory read-only, which (on most platforms) suffices to prevent the removal of its files. Fixes #35117 Updates #29921 Change-Id: Ica4e2818566f8c14df3eed7c3b8de5c0abeb6963 Reviewed-on: https://go-review.googlesource.com/c/go/+/203502 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Change https://golang.org/cl/223700 mentions this issue: |
…moveAllWithMoreErrorThanReqSize Previously we injected an error, and the injection points were (empirically) not realistic on some platforms. Instead, we now make the directory read-only, which (on most platforms) suffices to prevent the removal of its files. Also remove unused test hook, as was done in CL 204060. For #35117. For #29921. Fixes #37895. Change-Id: Ica4e2818566f8c14df3eed7c3b8de5c0abeb6963 Reviewed-on: https://go-review.googlesource.com/c/go/+/203502 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit 06bdd52) Reviewed-on: https://go-review.googlesource.com/c/go/+/223700 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes - the behavior can still be traced in the source of the master branch.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Create a directory
parent
with more than 1024 files in it owned by the non-current user. This behavior originally presented itself with a directory mounted in Docker that created 1050 root-owned files locale files. The following script creates a directory parent with such contents.Then, run the following go program in the same directory.
What did you expect to see?
A program terminating with a permissions error.
What did you see instead?
A non-terminating program. Inspecting the program with strace shows the same set of unlink attempts and permissions errors. This is due to the following loop, which attempts to delete the contents of the
parent
directory in batches of 1024.go/src/os/removeall_at.go
Line 89 in ba1de79
This logic is subtly wrong, as if all 1024 files cannot be deleted, recurseErr will be set (and not read within the loop) and the subsequent Readdir call will return the same set of filenames. This logic will also be problematic for any directory containing at least 1024 files which cannot be deleted.
The text was updated successfully, but these errors were encountered: