瀏覽代碼

unix: fix TestMmap crash on openbsd/386

When adding Mprotect to TestMmap in CL 56172, PROT_WRITE was implicitly
assumed to also include PROT_READ. This is not necessarily true on all
OSes and makes TestMmap crash on openbsd/386.

As suggested my Mikio Hara fix it by also setting PROT_READ on the
memory mapping.

Fixes golang/go#21962

Change-Id: Ia789ab8b31f8dec0c3db23cc950ccdd4aab3db05
Reviewed-on: https://go-review.googlesource.com/65230
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser 8 年之前
父節點
當前提交
2320a9c158
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      unix/mmap_unix_test.go

+ 1 - 1
unix/mmap_unix_test.go

@@ -17,7 +17,7 @@ func TestMmap(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatalf("Mmap: %v", err)
 		t.Fatalf("Mmap: %v", err)
 	}
 	}
-	if err := unix.Mprotect(b, unix.PROT_WRITE); err != nil {
+	if err := unix.Mprotect(b, unix.PROT_READ|unix.PROT_WRITE); err != nil {
 		t.Fatalf("Mprotect: %v", err)
 		t.Fatalf("Mprotect: %v", err)
 	}
 	}