Skip to content

Commit 71218db

Browse files
runtime: don't mlock on Ubuntu 5.4 systems
For #35777 For #37436 Fixes #40184 Change-Id: I68561497d9258e994d1c6c48d4fb41ac6130ee3a Reviewed-on: https://go-review.googlesource.com/c/go/+/244059 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 11f92e9 commit 71218db

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/runtime/os_linux_x86.go

+34-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
package runtime
99

10-
import "runtime/internal/atomic"
10+
import (
11+
"runtime/internal/atomic"
12+
"unsafe"
13+
)
1114

1215
//go:noescape
1316
func uname(utsname *new_utsname) int
@@ -55,6 +58,36 @@ func osArchInit() {
5558
return
5659
}
5760

61+
if major == 5 && minor == 4 && patch < 2 {
62+
// All 5.4 versions of Ubuntu are patched.
63+
procVersion := []byte("/proc/version\000")
64+
f := open(&procVersion[0], _O_RDONLY, 0)
65+
if f >= 0 {
66+
var buf [512]byte
67+
p := noescape(unsafe.Pointer(&buf[0]))
68+
n := read(f, p, int32(len(buf)))
69+
closefd(f)
70+
71+
needle := []byte("Ubuntu")
72+
contains:
73+
for i, c := range buf[:n] {
74+
if c != needle[0] {
75+
continue
76+
}
77+
if int(n)-i < len(needle) {
78+
break
79+
}
80+
for j, c2 := range needle {
81+
if c2 != buf[i+j] {
82+
continue contains
83+
}
84+
}
85+
// This is an Ubuntu system.
86+
return
87+
}
88+
}
89+
}
90+
5891
if major == 5 && (minor == 2 || minor == 3 && patch < 15 || minor == 4 && patch < 2) {
5992
gsignalInitQuirk = mlockGsignal
6093
if m0.gsignal != nil {

0 commit comments

Comments
 (0)