Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: re-enable GOTRACEBACK=crash on macOS #59446

Closed
krader1961 opened this issue Apr 5, 2023 · 7 comments
Closed

runtime: re-enable GOTRACEBACK=crash on macOS #59446

krader1961 opened this issue Apr 5, 2023 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@krader1961
Copy link

A recent discussion on the go-nuts mailing list had myself, and Robert Engels, confused why we didn't get core dumps when a process written in Go died from a signal such as SIGSEGV on our macOS platforms. The reason core dumps don't happen on macOS (at least on amd64) can be found in src/runtime/signal_unix.go:

//go:nosplit
func crash() {
    // OS X core dumps are linear dumps of the mapped memory,
    // from the first virtual byte to the last, with zeros in the gaps.
    // Because of the way we arrange the address space on 64-bit systems,
    // this means the OS X core file will be >128 GB and even on a zippy
    // workstation can take OS X well over an hour to write (uninterruptible).
    // Save users from making that mistake.
    if GOOS == "darwin" && GOARCH == "amd64" {
        return
    }

    dieFromSignal(_SIGABRT)
}

This should be documented. It is also unclear why the GOARCH restriction exists. Presumably the same issue affects macOS on arm64 (aka, Apple Silicon). However, I have not verified that since it requires creating a code-signed Go binary and I didn't have the necessary desire to jump through those hoops.

@Joumax14
Copy link

Joumax14 commented Apr 5, 2023

I agree

@mknyszek mknyszek changed the title Documentation for GOTRACEBACK=crash should mention macOS limitation runtime: documentation for GOTRACEBACK=crash should mention macOS limitation Apr 5, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 5, 2023
@mknyszek mknyszek added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed compiler/runtime Issues related to the Go compiler and/or runtime. labels Apr 5, 2023
@mknyszek mknyszek added this to the Backlog milestone Apr 5, 2023
@ianlancetaylor
Copy link
Contributor

The comment seems reasonably explanatory. At the time that the comment was written, dumping core on an amd64 running macOS generated a truly gigantic file. Doing that would serve nobody well. Perhaps macOS has changed since then.

@ianlancetaylor
Copy link
Contributor

That is to say: somebody with a Mac should check whether the comment is still true. Thanks.

@krader1961
Copy link
Author

The comment seems reasonably explanatory.

Yes, the source code comment is quite clear. My point (which I didn't make crystal clear) is that the documentation of GOTRACEBACK at https://pkg.go.dev/runtime does not include similar text. Leaving developers on macOS wondering why they aren't getting core files from their programs written in Go. Developers writing in Go shouldn't have to go spelunking through the Go source to figure this out. 😸

somebody with a Mac should check whether the comment is still true

I verified that on macOS 13.2 (Ventura) on Apple Silicon (specifically an Apple M1 Max server) it is not a problem to generate core dumps from a Go binary. The core dump is a reasonable size (comparable to any I generate from a program written in C). Note that I had to follow the directions I found at https://developer.apple.com/forums/thread/694233. Specifically, how to self-sign a Go binary so that the OS would generate a core dump from it. It appears the code signing requirements goes back to macOS 12 (Monterey), if not farther back.

I'll check whether it is still an issue on my older MacBook Pro (which I think is running macOS 12 and using the amd64 architecture). The question then becomes what to do if it isn't an issue on that relatively new macOS release but is still a problem on older macOS releases supported by Go? My vote is to remove the restriction since core dumps are disabled by default and anyone enabling core dumps should know what they are doing. It may still be a good idea to add a "dragons be here" warning to the https://pkg.go.dev/runtime text.

@krader1961
Copy link
Author

I verified that on macOS 11.7;5 (BigSur), on an amd64 architecture, if I elide the GOOS darwin check in the crash() function I get a core dump of a reasonable size. So the current limitation on
Darwin core dumps no longer seems to be necessary.

@bcmills bcmills added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 6, 2023
@ianlancetaylor
Copy link
Contributor

Thanks for checking. Sent https://go.dev/cl/483015 to remove that oddity.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/483015 mentions this issue: runtime: permit core dumps in darwin-amd64

gopherbot pushed a commit that referenced this issue Apr 7, 2023
Previously we did not permit them as Go programs generated enormous
core dumps on macOS. However, according to an investigation in #59446,
they are OK now.

For #59446

Change-Id: I1d7a3f500a6bc525aa6de8dfa8a1d8dbb15feadc
Reviewed-on: https://go-review.googlesource.com/c/go/+/483015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
@bcmills bcmills changed the title runtime: documentation for GOTRACEBACK=crash should mention macOS limitation runtime: re-enable GOTRACEBACK=crash on macOS Apr 7, 2023
@golang golang locked and limited conversation to collaborators Apr 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants