Skip to content

Commit

Permalink
feat: enable GORACE=halt_on_panic=1 in machined binary
Browse files Browse the repository at this point in the history
Fixes: #3533

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
  • Loading branch information
Unix4ever authored and talos-bot committed May 25, 2021
1 parent 0acb04a commit 7235976
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ require (
github.com/talos-systems/crypto v0.2.1-0.20210427105118-4f80b976b640
github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0
github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0
github.com/talos-systems/go-debug v0.2.0
github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3
github.com/talos-systems/go-kmsg v0.1.0
github.com/talos-systems/go-loadbalancer v0.1.1
github.com/talos-systems/go-procfs v0.0.0-20210108152626-8cbc42d3dc24
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,8 @@ github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0 h1:
github.com/talos-systems/go-blockdevice v0.2.1-0.20210510233948-1292574643e0/go.mod h1:qnn/zDc09I1DA2BUDDCOSA2D0P8pIDjN8pGiRoRaQig=
github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0 h1:DI+BjK+fcrLBc70Fi50dZocQcaHosqsuWHrGHKp2NzE=
github.com/talos-systems/go-cmd v0.0.0-20210216164758-68eb0067e0f0/go.mod h1:kf+rZzTEmlDiYQ6ulslvRONnKLQH8x83TowltGMhO+k=
github.com/talos-systems/go-debug v0.2.0 h1:IbBfDSJE7tUaSXKuytOksHFI/wAbU2/1/szGvnKpgqc=
github.com/talos-systems/go-debug v0.2.0/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3 h1:beG97JtuU5oIL+ArSOKbJxbfsCfELOQ5VZu4RuSBJHU=
github.com/talos-systems/go-debug v0.2.1-0.20210525175311-3d0a6e1bf5e3/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
github.com/talos-systems/go-kmsg v0.1.0 h1:juoZn+XioduYvtie6nqi/miKGJPLYSBNXRv5jRe6+lE=
github.com/talos-systems/go-kmsg v0.1.0/go.mod h1:dppwQn+/mrdvsziGMbXjzfc4E+75oZhr39UIP6LgL0w=
github.com/talos-systems/go-loadbalancer v0.1.1 h1:qjC0uWHu6O7VXG9EN4ovVPg79sRbypXTrJZJskdaa2k=
Expand Down
5 changes: 5 additions & 0 deletions internal/app/machined/pkg/system/services/apid.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/containerd/containerd/oci"
"github.com/fsnotify/fsnotify"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/talos-systems/go-debug"

"github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
Expand Down Expand Up @@ -138,6 +139,10 @@ func (o *APID) Runner(r runtime.Runtime) (runner.Runner, error) {
}
}

if debug.RaceEnabled {
env = append(env, "GORACE=halt_on_error=1")
}

b, err := r.Config().Bytes()
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions internal/app/machined/pkg/system/services/trustd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/containerd/containerd/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/talos-systems/go-debug"

"github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
"github.com/talos-systems/talos/internal/app/machined/pkg/system/events"
Expand Down Expand Up @@ -72,6 +73,10 @@ func (t *Trustd) Runner(r runtime.Runtime) (runner.Runner, error) {
env = append(env, fmt.Sprintf("%s=%s", key, val))
}

if debug.RaceEnabled {
env = append(env, "GORACE=halt_on_error=1")
}

b, err := r.Config().Bytes()
if err != nil {
return nil, err
Expand Down
11 changes: 10 additions & 1 deletion internal/pkg/mount/switchroot/switchroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"os"

"github.com/talos-systems/go-debug"
"golang.org/x/sys/unix"

"github.com/talos-systems/talos/internal/pkg/mount"
Expand Down Expand Up @@ -60,7 +61,15 @@ func Switch(prefix string, mountpoints *mount.Points) (err error) {
// convention.
log.Println("executing /sbin/init")

if err = unix.Exec("/sbin/init", []string{"/sbin/init"}, []string{}); err != nil {
envv := []string{}

if debug.RaceEnabled {
envv = append(envv, "GORACE=halt_on_error=1")

log.Printf("race detection enabled with halt_on_error=1")
}

if err = unix.Exec("/sbin/init", []string{"/sbin/init"}, envv); err != nil {
return fmt.Errorf("error executing /sbin/init: %w", err)
}

Expand Down

0 comments on commit 7235976

Please sign in to comment.