From d15586390a95a4b7577fb6b23f08f8fe033376ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 21 Jan 2020 13:38:26 +0100 Subject: [PATCH] Lock access to S.cache --- GetRuntimeAddresses/symbolyze/symbolyze.go | 5 +++++ 1 file changed, 5 insertions(+) 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 }