-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
V2Ray 5.4.1 crash fatal error: concurrent map read and map write #2523
Comments
Please describe when the error occurs, when the program starts running or after running for a while? |
it was early after starting. |
Cloud you provide your configuration? |
what part of it is important? It is big configuration: >200k The same configuration was running smooth for week beforehand. |
I have no clue, the code in question hasn't been changed in three months. |
I updated the logs to include the beginning of error occurred. |
@4-FLOSS-Free-Libre-Open-Source-Software @xiaokangwang @AkinoKaede v2ray-core/app/dispatcher/default.go Line 216 in acbb5e6
this goroutine concurrent map read and map write.
I prefer the first solution, but the logic here is very complicated, I didn't dig deeper, I'm not sure if here can not use goroutine, I hope it can help you. |
I tried the unstable release V2Ray 5.7.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20.4 linux/amd64) and it is still crashing multiple times every day with this error. |
@4-FLOSS-Free-Libre-Open-Source-Software You can try modify go d.routedDispatch(ctx, outbound, destination) => d.routedDispatch(ctx, outbound, destination) |
I tried that. But then unfortunately, DNS reproducible stops working with same config but works with release v5.7.1. |
I guess the reason for this is a certain function in upper function stack calls I tried to reproduce that showd above by constructing a config file, but I failed. But I think the bug might be fixed by adding a lock to the data structure diff --git a/app/router/weight.go b/app/router/weight.go
index ec7711b9..8d217241 100644
--- a/app/router/weight.go
+++ b/app/router/weight.go
type weightScaler func(value, weight float64) float64
@@ -26,16 +27,19 @@ type WeightManager struct {
...
+ mu sync.Mutex
}
// Get gets the weight of specified tag
func (s *WeightManager) Get(tag string) float64 {
+ s.mu.Lock()
weight, ok := s.cache[tag]
...
s.cache[tag] = weight
+ s.mu.Unlock()
return weight
} You could give it a try :) |
@KujouRinka yes. The d.routedDispatch() is not thread safe. But if no goroutine here mutex will no need, or maybe just add a comment not thread safe. The key is why goroutine is used here? does here can not use goroutine? |
Using goroutine is necessary. I think we can fix it by add mutex. |
@KujouRinka Could you please submit a Pull Request? |
@AkinoKaede Sure! see #2678. |
This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days |
What version of V2Ray are you using?
v2ray version
V2Ray 5.4.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.20.2 linux/amd64)
A unified platform for anti-censorship
What's your scenario of using V2Ray?
What problems have you encountered?
What's your expectation?
Please attach your configuration here
Server configuration:
// Please attach your server configuration here.
Client configuration:
// Please attach your client configuration here.
Please attach error logs here
Server error log:
// Please attach your server error log here.
Client error log:
// Please attach your client error log here.
Please attach access log here
// Please attach your server access log here.
Other configurations (such as Nginx) and logs here
If V2Ray cannot start up, please attach output from
--test
commandIf V2Ray service is abnormal, please attach journal log here
The text was updated successfully, but these errors were encountered: