diff --git a/GetRuntimeAddresses/symbolyze/symbolyze.go b/GetRuntimeAddresses/symbolyze/symbolyze.go index 79d565e..4710f94 100644 --- a/GetRuntimeAddresses/symbolyze/symbolyze.go +++ b/GetRuntimeAddresses/symbolyze/symbolyze.go @@ -335,9 +335,12 @@ func (S *Scanner) searchSymbolInPid(pid int) (offset uint64, found bool) { func (S *Scanner) findSymbolInELF(pathname string) (offset uint64, found bool) { // 0. Return the value from the cache, if found. + S.RLock() if offset, found = S.cache[pathname]; found { + S.RUnlock() return offset, found } + S.RUnlock() // 1. Open the file with the ELF-parser file, err := elf.Open(pathname) @@ -390,7 +393,9 @@ func (S *Scanner) findSymbolInELF(pathname string) (offset uint64, found bool) { // 6. Store this calculation in our cache so that we don't to touch // this file again. + S.Lock() S.cache[pathname] = vmOffset + S.Unlock() return vmOffset, true }