Skip to content

Commit 6fa06d9

Browse files
aegistudioaclements
authored andcommitted
runtime: prevent stack growth after fork in runtime.sigfillset
This fixes the unexpected growth of stack in child process, which is caused by stack checking code in runtime.sigfillset called from runtime.sigset while clearing the signal handlers in child process. The redundant stack checking code is generated due to missing '//go:nosplit' directive that should be annotated for runtime.sigfillset. Fixes #43066 Updates #21314 Change-Id: I9483a962a4b0747074313991841e2440ee32198c Reviewed-on: https://go-review.googlesource.com/c/go/+/276173 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent ae9b442 commit 6fa06d9

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

src/runtime/os_linux_be64.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
3838
*mask &^= 1 << (uint(i) - 1)
3939
}
4040

41+
//go:nosplit
4142
func sigfillset(mask *uint64) {
4243
*mask = ^uint64(0)
4344
}

src/runtime/os_linux_generic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func sigdelset(mask *sigset, i int) {
3838
(*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
3939
}
4040

41+
//go:nosplit
4142
func sigfillset(mask *uint64) {
4243
*mask = ^uint64(0)
4344
}

src/runtime/os_linux_mips64x.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func sigdelset(mask *sigset, i int) {
4848
(*mask)[(i-1)/64] &^= 1 << ((uint32(i) - 1) & 63)
4949
}
5050

51+
//go:nosplit
5152
func sigfillset(mask *[2]uint64) {
5253
(*mask)[0], (*mask)[1] = ^uint64(0), ^uint64(0)
5354
}

src/runtime/os_linux_mipsx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func sigdelset(mask *sigset, i int) {
4242
(*mask)[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
4343
}
4444

45+
//go:nosplit
4546
func sigfillset(mask *[4]uint32) {
4647
(*mask)[0], (*mask)[1], (*mask)[2], (*mask)[3] = ^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)
4748
}

0 commit comments

Comments
 (0)