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: nil pointer dereference hangs on macos instead of panicking. #50322
Comments
I cannot reproduce on my machine either. Are you using anything like an antivirus software, or some kind of crash handler? I don't think it is the runtime that causes it to hang, so it probably cannot detect and emit an error either. |
Yes. I also suspect that it's the pre-installed security software that causes this. I managed to disable it today and the problem did go away.
Sure, but I wonder what action the runtime trying to do that has been blocked? If it's something like memory access or syscall, shouldn't the action return an error or maybe timeout? I also tried getting the goroutine profile in a seperate go routine to figure out what's going on.: package main
import (
"log"
"runtime"
"time"
)
func main() {
go func() {
time.Sleep(time.Second)
records := make([]runtime.StackRecord, runtime.NumGoroutine())
log.Println("running GoroutineProfile")
log.Println(runtime.GoroutineProfile(records))
log.Println("GoroutineProfile:", records)
}()
var a *int
*a += 1
log.Println(a)
} I can see the log |
BTW the software seems to cause the problem is Symantec Endpoint Protection. My colleagues with the same software enabled kindly helped me running the same program on their machines, but none can reproduce the problem :( |
The same problem can be reproduced with c. #include <stdio.h>
int main() {
int *a = NULL;
int b = *a;
return 0;
} The only difference is that the c program can be stopped with <ctrl+c>, and sometimes it stopped after blocking for a few minutes without printing any error. Looks like this is not language specific, and the runtime probably can't do anything about it, please feel free to close this issue if no further actions is needed. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputI removed GOPRIVATE, GOPROXY, GONOPROXY, GONOSUMDB from the output, which contains internal domains of my company. They're likely not related to this issue.
What did you do?
I created a new module with
go mod init
and built the following program withgo build -o main
Then run
./main
What did you expect to see?
The program panics for nil pointer dereference.
What did you see instead?
The program hangs, and can't be stopped with <ctrl+c> or
kill
command. I had to usekill -9
to kill it.If I run it with
sudo
, the program panics as expected.Runtime error like index out of range panics as expected with or without sudo.
It looks like this is an issues specific to the machine I'm using. I run the same compiled binary on different macos machines, but unable to reproduce the same hanging problem.
I'm not sure what exactly happened under the hood, but maybe something is blocking the access of the invalid address 0x0. I understand it's probably impossible to consistently reproduce this elsewhere, so I hope someone can give me some direction for debugging this. Also I think the runtime should produce some kind of error instead of just hanging.
The text was updated successfully, but these errors were encountered: