From ea995a9bebeb82e7e7f2c087bb15ca431586dc42 Mon Sep 17 00:00:00 2001 From: Stavros Panakakis Date: Mon, 6 May 2024 03:31:47 +0300 Subject: [PATCH 1/3] internal/crashmonitor: add the options parameter to the setCrashOutput --- internal/crashmonitor/monitor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/crashmonitor/monitor.go b/internal/crashmonitor/monitor.go index f475f7e..2562adb 100644 --- a/internal/crashmonitor/monitor.go +++ b/internal/crashmonitor/monitor.go @@ -26,7 +26,7 @@ import ( // TODO(adonovan): eliminate once go1.23+ is assured. func Supported() bool { return setCrashOutput != nil } -var setCrashOutput func(*os.File) error // = runtime.SetCrashOutput on go1.23+ +var setCrashOutput func(*os.File, debug.CrashOptions) error // = runtime.SetCrashOutput on go1.23+ // Parent sets up the parent side of the crashmonitor. It requires // exclusive use of a writable pipe connected to the child process's stdin. @@ -34,7 +34,7 @@ func Parent(pipe *os.File) { writeSentinel(pipe) // Ensure that we get pc=0x%x values in the traceback. debug.SetTraceback("system") - setCrashOutput(pipe) + setCrashOutput(pipe, debug.CrashOptions{}) } // Child runs the part of the crashmonitor that runs in the child process. From 5a429a9f3b0ef4b71495b1e10fac2993bdf72004 Mon Sep 17 00:00:00 2001 From: Stavros Panakakis Date: Mon, 6 May 2024 23:31:13 +0300 Subject: [PATCH 2/3] internal/crashmonitor: update the type of the setCrashOutput function --- internal/crashmonitor/crash_go123.go | 9 +++++++-- internal/crashmonitor/monitor.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/crashmonitor/crash_go123.go b/internal/crashmonitor/crash_go123.go index 2e0c1b3..2ec621b 100644 --- a/internal/crashmonitor/crash_go123.go +++ b/internal/crashmonitor/crash_go123.go @@ -7,8 +7,13 @@ package crashmonitor -import "runtime/debug" +import ( + "os" + "runtime/debug" +) func init() { - setCrashOutput = debug.SetCrashOutput + setCrashOutput = func(f *os.File) error { + return debug.SetCrashOutput(f) + } } diff --git a/internal/crashmonitor/monitor.go b/internal/crashmonitor/monitor.go index 2562adb..f475f7e 100644 --- a/internal/crashmonitor/monitor.go +++ b/internal/crashmonitor/monitor.go @@ -26,7 +26,7 @@ import ( // TODO(adonovan): eliminate once go1.23+ is assured. func Supported() bool { return setCrashOutput != nil } -var setCrashOutput func(*os.File, debug.CrashOptions) error // = runtime.SetCrashOutput on go1.23+ +var setCrashOutput func(*os.File) error // = runtime.SetCrashOutput on go1.23+ // Parent sets up the parent side of the crashmonitor. It requires // exclusive use of a writable pipe connected to the child process's stdin. @@ -34,7 +34,7 @@ func Parent(pipe *os.File) { writeSentinel(pipe) // Ensure that we get pc=0x%x values in the traceback. debug.SetTraceback("system") - setCrashOutput(pipe, debug.CrashOptions{}) + setCrashOutput(pipe) } // Child runs the part of the crashmonitor that runs in the child process. From 6f5eb73c340be46940728bf6effd5a0370e4c204 Mon Sep 17 00:00:00 2001 From: Stavros Panakakis Date: Tue, 7 May 2024 00:06:57 +0300 Subject: [PATCH 3/3] internal/crashmonitor: add todo comment for the setCrashOutput lambda --- internal/crashmonitor/crash_go123.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/crashmonitor/crash_go123.go b/internal/crashmonitor/crash_go123.go index 2ec621b..46ec252 100644 --- a/internal/crashmonitor/crash_go123.go +++ b/internal/crashmonitor/crash_go123.go @@ -13,6 +13,7 @@ import ( ) func init() { + // TODO(adonovan): remove temporary lambda when the SetCrashOutput transition (#67182) is complete. setCrashOutput = func(f *os.File) error { return debug.SetCrashOutput(f) }