-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: hangs on Windows due to McAfee's mfehcinj.dll apparently hijacking or suspending threads #42528
Comments
I am not sure about this problem. It "freezes" on many different parts in go, e.g.
With goroutines
or on command:
I am quite confused with this behavior. |
@ybbus, unfortunately those goroutine traces are not particularly helpful: the goroutines waiting in The later traces show a program that does not appear to be deadlocked.
is in a conditional after having successfully read a byte from a go/src/cmd/go/internal/imports/read.go Line 46 in 1f2e58d
is in a loop after having read a file to be hashed:
So I'm not sure what to make of this: it looks like a running program, albeit possibly one that is running slowly. (Is it possible that you're seeing slowness due to, say, filesystem contention?) |
@bcmills What I can tell you is, that the last two go-routines you mentioned are indeed "stuck". I also cannot explain why this doesn't happen with GOMAXPROCS=1. I would appreciate if someone has a hint for me how to better approach this problem. Could some anti-virus software be the problem here? blocking file-access / forbid memory allocation...? |
Looked a bit more into this. What I also observed, that I cannot really nail it down to some code line. It seems to happen random on any line of code, and also on any part in the execution but mostly when go build is executing (maybe since this takes most of the runtime). But what seems to be in common is, that the end of the stack on that goroutine lokks like this:
To be honest I am not very familiar with this low level stuff, but for me it seems like that a preemtion happens for the goroutine currently running, and it never ever wakes up later on. Also not very deterministic: The lower GOMAXPROCS is, the lower is the chance this issue happens, with 1 and 2 it did not happen yet. |
I think the answer to that is always “maybe”. 😅
The |
A couple more diagnostic questions:
|
Bryan: When I run other programs locally there was no issue yet. For installing I always download the windows archive and extract it to my machine. Yes, MCAfee is installed, but I was allowed to completely disable it (corporate machine) for testing, and it did not change anything. Is ther an easy way to check with dlv, what the program is really doing at the moment or why (for what) it is waiting? |
try passing the -x flag to go build with both the GOMAXPROCS 1 and 8 scenarios. Please provide the entire output |
Hi Dave, It seems that even though I disabled most of the McAfee stuff, it still tries to be part of the problem I think. The stack of all threads of the hanging go processes look the same and seem to "WaitForSingleObject". The only stack that looks different is the one that also seems to have something injected from McAfee. I know too little of the low level windows os stuff to have some opinion about this, but for me it actually looks like some issue with mcafee. I just don't get, why there are tons of programs running on my machine that don't have a similar problems with McAffe. Seems to be something go specific? Also it is quite strange that GOMAXPROCS seems to make a huge difference here. |
Dave:
otherwise with MAXPROCS=1
|
Just another thought: MAXPROCS=1 MAXPROCS=8 That is my guess and would fit to my following observation: The build again runs smoothly, when setting GOMAXPROCS to a high value like 256. Maybe this is enough on the one hand for go itself and on the other hand also for mcafee to do whatever it does... 64 and 128 for example still does not seem to be enough --> again always hanging 256 only works when directly invoking go build. Any thoughts on that? |
Seems this is a bug in mcafee av |
It is possible that the McAfee DLL is hijacking the threads when the Go runtime makes a system call under the assumption that every thread “probably” makes a system call eventually. Some Go threads essentially never make system calls, so they would not be hijackable. That may be what leads to the observed deadlock. If that is correct, then a workaround on the Go side might look like the workaround for #18717 (CL 35494), in which threads controlled by the Go runtime periodically make an inexpensive but otherwise needless call to an arbitrary function in the C standard library in order to allow hooks embedded in that library to run on the thread. That said, even if this hypothesis is correct I would rather have McAfee fix their faulty assumption than us work around it. |
(And by the way, @ybbus, thanks for the detailed investigation of what's running on those threads!) |
I'd imagine you can configure McAfee to ignore your program. This problem is not unique to McAfee; we've heard reports where the Go toolchain runs fine, but the binaries it builds fail due to AV interference. |
Sorry I don't know enough to comment.
I agree. This might help. I have similar unresolved issue #36492. @aclements thinks it is my buggy antivirus program. Mind you, it is different antivirus vendor. Alex |
@networkimprov @bcmills What are the implications of using this flag in my daily development? Is it ok to let this enabled all the time? Never the less I will ask the IT guys to forward this to McAfee, since the should really care about behaving nicely to foreign processes. |
You're probably better off setting asyncpreemptoff, which switches the runtime to cooperative scheduling of goroutines on available cores (GOMAXPROCS) -- it was the default until 1.14. Since that fixes it, maybe McAfee (or your IT dept) has an update planned. |
IT dept allowed to uninstall McAfee temporary --> issue disappeard Unfortunatly after reinstalling McAfee, issue is still gone. I will leave it with that, and if the issue again comes up ask the IT guys to talk to McAfee about that. Thanks for all your help. I now have at least some good short term workaround options to continue working when the issue comes up again. From my side, this issue may be closed and hopefully helps other devs to faster get to the root cause of this problem (took me quite a while to be honest) |
Thanks for following up. Closing because it doesn't seem that there is anything we can change in Go to fix this. |
I disagree. I think Go should have asyncpreemptoff=1 by default on Windows. None of our Windows users complained about preemption being a problem, but now @ybbus and I are suffering. So far, we only know about developers are affected. But maybe this also affects users who run our programs. And, while I agree that the problem is most likely with buggy antivirus software, that is the world we have to live in. Alex |
That's a good point. I wondered why async preemption was rolled out as the default, instead of an option. To make matters worse, we can't disable it in a build, and my proposal to allow that was quickly rejected, #40870. |
Lets take async preemption on Windows to a different issue, not this one. Thanks. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I can reproduce it very regularly at least on my system.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I experienced a lot of freezes for several days now, when using the command:
go generate ./..
in one of my projects.
go generate
does trigger four different mockgen commands, thats all.These mockgen commands in turn trigger some
go list
andgo build
commands, which freeze very often.I don't think it has anything to do with go generate or mockgen. It just seems to trigger the issue more often as when I just do
go build
. But alsogo build
as a standalone command sometimes triggered this issue.What did you expect to see?
Successful execution of all go commands that were called from go generate --> mockgen.
What did you see instead?
The main issue here is, that
go build
and alsogo list
that is executed by mockgen freezes very often.In windows, by using a process monitor tool, I can see, that
go generate
calledmockgen
that in turn calledgo build
.It happens very often, that the
go build -o prog.bin.exe prog.go
process is does not return and seems to be stuck.I also found out, when setting GOMAXPROCS=1,
go generate ./...
works perfectly without a single one of this issues appearing.Furthermore when
go build
was stuck I attached with dlv and got the following list of goroutines:The following goroutines are waiting at the provided code lines:
I think the other goroutines are not that interesting, they look like this:
As mentioned, this issue does not appear, when using GOMAXPROCS=1.
Otherwise it appears nearly always.
Any idea?
The text was updated successfully, but these errors were encountered: