-
Notifications
You must be signed in to change notification settings - Fork 543
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
Possible data race in the logger? #1487
Comments
Automatics does see a possible error here. As the person who wrote this, I don't see any possible real errors here. |
Is it possible that in |
Of course this function is called simultaneously from different goroutines. In very rare cases, this can result in slightly messed up logs. But in my opinion it will never lead to panic or anything really scary. This is intentional behavior, logs should not slow down the program. I don't like the race warnings either. But I don't know how to get around them without using mutexes. |
I see, thanks for your reply. Should I see it as a "benign race" (a race that has no harm on the program behavior) ? |
Try analyzing the code. Whether it can lead to significant errors. In my opinion, no: Lines 116 to 144 in d7cdc8b
|
Maybe this is a buffer overflow error? Suppose at some time, Both goroutine pass the check Later at line 142, when accessing Does this make sense? |
Looks like you right |
Thank you for your response! |
I'm using the v1.9.7 - 2024-11-11 release.
After I run the command
go build -race && ./go2rtc
to build go2rtc together with race detector, some race reports are printed.Looks like this is caused by the logger under
go2rtc/internal/app/log.go
. Thefunc (b *circularBuffer) Write(p []byte) (n int, err error)
method is not protected by mutex, so that during initialization phase, when multiple goroutines try to write to the buffer concurrently, data races could appear.The text was updated successfully, but these errors were encountered: