From: Michael Pratt Date: Mon, 2 Oct 2023 19:55:29 +0000 (-0400) Subject: syscall: copy original rlimit before modifying X-Git-Tag: go1.22rc1~708 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=122b35e838af8ab9c0d5027741d6f73cef09f966;p=gostls13.git 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 Auto-Submit: Michael Pratt TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- diff --git a/src/syscall/rlimit.go b/src/syscall/rlimit.go index fdc0d1bf1f..d77341bde9 100644 --- a/src/syscall/rlimit.go +++ b/src/syscall/rlimit.go @@ -31,9 +31,10 @@ func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(&lim) - lim.Cur = lim.Max - adjustFileLimit(&lim) - setrlimit(RLIMIT_NOFILE, &lim) + nlim := lim + nlim.Cur = nlim.Max + adjustFileLimit(&nlim) + setrlimit(RLIMIT_NOFILE, &nlim) } }