Skip to content

Commit a22cb5c

Browse files
committed
runtime/debug: eliminate temporary variadicity from SetCrashOutput
Updates #67182 Change-Id: I33fc8c515f4a9d120262ba30f61aea80ede5e9f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/585420 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Austin Clements <austin@google.com>
1 parent 6cd066f commit a22cb5c

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

api/next/42888.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pkg runtime/debug, type CrashOptions struct #67182
2-
pkg runtime/debug, func SetCrashOutput(*os.File, ...CrashOptions) error #42888
2+
pkg runtime/debug, func SetCrashOutput(*os.File, CrashOptions) error #42888

src/runtime/debug/example_monitor_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func monitor() {
9191
if err != nil {
9292
log.Fatalf("StdinPipe: %v", err)
9393
}
94-
debug.SetCrashOutput(pipe.(*os.File)) // (this conversion is safe)
94+
debug.SetCrashOutput(pipe.(*os.File), debug.CrashOptions{}) // (this conversion is safe)
9595
if err := cmd.Start(); err != nil {
9696
log.Fatalf("can't start monitor: %v", err)
9797
}

src/runtime/debug/stack.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ type CrashOptions struct {
4646
// To disable this additional crash output, call SetCrashOutput(nil).
4747
// If called concurrently with a crash, some in-progress output may be written
4848
// to the old file even after an overriding SetCrashOutput returns.
49-
//
50-
// TODO(adonovan): the variadic ... is a short-term measure to avoid
51-
// breaking the call in x/telemetry; it will be removed before the
52-
// go1.23 freeze.
53-
func SetCrashOutput(f *os.File, opts ...CrashOptions) error {
54-
if len(opts) > 1 {
55-
panic("supply at most 1 CrashOptions")
56-
}
49+
func SetCrashOutput(f *os.File, opts CrashOptions) error {
5750
fd := ^uintptr(0)
5851
if f != nil {
5952
// The runtime will write to this file descriptor from

src/runtime/debug/stack_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os/exec"
1414
"path/filepath"
1515
"runtime"
16+
"runtime/debug"
1617
. "runtime/debug"
1718
"strings"
1819
"testing"
@@ -29,7 +30,7 @@ func TestMain(m *testing.M) {
2930
if err != nil {
3031
log.Fatal(err)
3132
}
32-
if err := SetCrashOutput(f); err != nil {
33+
if err := SetCrashOutput(f, debug.CrashOptions{}); err != nil {
3334
log.Fatal(err) // e.g. EMFILE
3435
}
3536
println("hello")

src/runtime/traceback_system_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func crash() {
2828
// Ensure that we get pc=0x%x values in the traceback.
2929
debug.SetTraceback("system")
3030
writeSentinel(os.Stdout)
31-
debug.SetCrashOutput(os.Stdout)
31+
debug.SetCrashOutput(os.Stdout, debug.CrashOptions{})
3232

3333
go func() {
3434
// This call is typically inlined.

0 commit comments

Comments
 (0)