aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/symbolizer
diff options
context:
space:
mode:
authorJoey Jiao <quic_jiangenj@quicinc.com>2024-05-09 08:17:44 +0800
committerDmitry Vyukov <dvyukov@google.com>2024-06-11 04:38:10 +0000
commit004eed1484ee57028a0173e51568305f19d657b6 (patch)
tree83a4b782db6e10d9d5489844cc89e220a241e8b3 /pkg/symbolizer
parent7ebc85f188458bfc8f06c402bd596f446627695d (diff)
pkg/symbolizzer: use thread safe sync.Map to avoid concurrency issue
Diffstat (limited to 'pkg/symbolizer')
-rw-r--r--pkg/symbolizer/cache.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/pkg/symbolizer/cache.go b/pkg/symbolizer/cache.go
index 370833953..65e34aae7 100644
--- a/pkg/symbolizer/cache.go
+++ b/pkg/symbolizer/cache.go
@@ -49,17 +49,14 @@ func (c *Cache) Symbolize(inner func(string, uint64) ([]Frame, error), bin strin
// buffer, it won't after interning (and won't prevent GC'ing of the large buffer).
// The type is not thread-safe.
type Interner struct {
- m map[string]string
+ m sync.Map
}
func (in *Interner) Do(s string) string {
- if in.m == nil {
- in.m = make(map[string]string)
- }
- if interned, ok := in.m[s]; ok {
- return interned
+ if interned, ok := in.m.Load(s); ok {
+ return interned.(string)
}
s = strings.Clone(s)
- in.m[s] = s
+ in.m.Store(s, s)
return s
}