Skip to content

Commit 122b35e

Browse files
prattmicgopherbot
authored andcommitted
syscall: copy original rlimit before modifying
CL 531516 converted origRlimitNofile from an atomic.Value to atomic.Pointer[Rlimit]. i.e., it changed from storing a value to storing a pointer. After storing a pointer to lim, the remainder of this function immediately modifies it, thus mutating the value pointer to by origRlimitNofile (and thus defeating the point of origRlimitNofile). This broke the android-amd64-emu builder because it is (apparently) the only builder where the original RLIMIT_NOFILE Cur != Max. TestRlimitRestored is skipped on every other builder. Change-Id: I12076350eeddfd221823ad651e7e7eca59d2bdcd Reviewed-on: https://go-review.googlesource.com/c/go/+/532100 Run-TryBot: Michael Pratt <[email protected]> Auto-Submit: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent ef3171c commit 122b35e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/syscall/rlimit.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ func init() {
3131
var lim Rlimit
3232
if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max {
3333
origRlimitNofile.Store(&lim)
34-
lim.Cur = lim.Max
35-
adjustFileLimit(&lim)
36-
setrlimit(RLIMIT_NOFILE, &lim)
34+
nlim := lim
35+
nlim.Cur = nlim.Max
36+
adjustFileLimit(&nlim)
37+
setrlimit(RLIMIT_NOFILE, &nlim)
3738
}
3839
}
3940

0 commit comments

Comments
 (0)