mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix test_app task-tree
Executing `select {}` to wait forever triggers Go runtime deadlock
detection and kills the child, causing the number actual processes
be less than expected.
PiperOrigin-RevId: 376298799
This commit is contained in:
committed by
gVisor bot
parent
e8fc815b6e
commit
394c6089c3
@@ -12,6 +12,7 @@ go_library(
|
||||
],
|
||||
visibility = ["//:sandbox"],
|
||||
deps = [
|
||||
"//pkg/sentry/watchdog",
|
||||
"//pkg/sync",
|
||||
"//runsc/config",
|
||||
"//runsc/specutils",
|
||||
|
||||
@@ -42,6 +42,7 @@ import (
|
||||
"github.com/cenkalti/backoff"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/sentry/watchdog"
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
"gvisor.dev/gvisor/runsc/config"
|
||||
"gvisor.dev/gvisor/runsc/specutils"
|
||||
@@ -184,6 +185,7 @@ func TestConfig(t *testing.T) *config.Config {
|
||||
conf.Network = config.NetworkNone
|
||||
conf.Strace = true
|
||||
conf.TestOnlyAllowRunAsCurrentUserWithoutChroot = true
|
||||
conf.WatchdogAction = watchdog.Panic
|
||||
return conf
|
||||
}
|
||||
|
||||
|
||||
@@ -160,14 +160,17 @@ func (c *taskTree) SetFlags(f *flag.FlagSet) {
|
||||
|
||||
// Execute implements subcommands.Command.
|
||||
func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interface{}) subcommands.ExitStatus {
|
||||
stop := testutil.StartReaper()
|
||||
defer stop()
|
||||
|
||||
if c.depth == 0 {
|
||||
log.Printf("Child sleeping, PID: %d\n", os.Getpid())
|
||||
select {}
|
||||
for {
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
}
|
||||
log.Printf("Parent %d sleeping, PID: %d\n", c.depth, os.Getpid())
|
||||
|
||||
log.Printf("Parent %d creating %d children, PID: %d\n", c.depth, c.width, os.Getpid())
|
||||
|
||||
stop := testutil.StartReaper()
|
||||
defer stop()
|
||||
|
||||
var cmds []*exec.Cmd
|
||||
for i := 0; i < c.width; i++ {
|
||||
@@ -175,7 +178,7 @@ func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa
|
||||
"/proc/self/exe", c.Name(),
|
||||
"--depth", strconv.Itoa(c.depth-1),
|
||||
"--width", strconv.Itoa(c.width),
|
||||
"--pause", strconv.FormatBool(c.pause))
|
||||
fmt.Sprintf("--pause=%t", c.pause))
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
@@ -190,7 +193,10 @@ func (c *taskTree) Execute(ctx context.Context, f *flag.FlagSet, args ...interfa
|
||||
}
|
||||
|
||||
if c.pause {
|
||||
select {}
|
||||
log.Printf("Parent %d sleeping, PID: %d\n", c.depth, os.Getpid())
|
||||
for {
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
}
|
||||
|
||||
return subcommands.ExitSuccess
|
||||
|
||||
Reference in New Issue
Block a user