Skip to content
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

Thread safety fix in logging and SetLevel #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yacovm
Copy link

@yacovm yacovm commented Sep 30, 2016

#104

When a logging is called concurrently with SetLevel, a panic occurs:
fatal error: concurrent map read and map write

goroutine 20 [running]:
runtime.throw(0x5f7cc0, 0x21)
/home/yacovm/OBC/go/src/runtime/panic.go:530 +0x90 fp=0xc820038d58 sp=0xc820038d40
runtime.mapaccess2_faststr(0x551020, 0xc820078780, 0x5c9cc8, 0x4, 0x10, 0x551820)
/home/yacovm/OBC/go/src/runtime/hashmap_fast.go:307 +0x5b fp=0xc820038db8 sp=0xc820038d58
_/home/yacovm/go-logging/go-logging.(_moduleLeveled).IsEnabledFor(0xc8200981e0, 0x4, 0x5c9cc8, 0x4, 0x0)
/home/yacovm/go-logging/go-logging/level.go:110 +0x62 fp=0xc820038e18 sp=0xc820038db8
_/home/yacovm/go-logging/go-logging.(_Logger).IsEnabledFor(0xc8200788a0, 0x4, 0x0)
/home/yacovm/go-logging/go-logging/logger.go:140 +0x4d fp=0xc820038e48 sp=0xc820038e18
_/home/yacovm/go-logging/go-logging.(_Logger).log(0xc8200788a0, 0x4, 0x0, 0xc8200d9b30, 0x1, 0x1)
/home/yacovm/go-logging/go-logging/logger.go:144 +0x2f fp=0xc820038eb8 sp=0xc820038e48
_/home/yacovm/go-logging/go-logging.(_Logger).Info(0xc8200788a0, 0xc8200d9b30, 0x1, 0x1)
/home/yacovm/go-logging/go-logging/logger.go:239 +0x51 fp=0xc820038ef0 sp=0xc820038eb8
_/home/yacovm/go-logging/go-logging.TestConcurrency(0xc8200a0120)
/home/yacovm/go-logging/go-logging/logger_test.go:73 +0x11f fp=0xc820038f68 sp=0xc820038ef0
testing.tRunner(0xc8200a0120, 0x6b8468)

I added a RWLock to protect the map and added a regression test that many times
fails without the locks

op#104

When a logging is called concurrently with SetLevel, a panic occurs:
fatal error: concurrent map read and map write

goroutine 20 [running]:
runtime.throw(0x5f7cc0, 0x21)
	/home/yacovm/OBC/go/src/runtime/panic.go:530 +0x90 fp=0xc820038d58 sp=0xc820038d40
runtime.mapaccess2_faststr(0x551020, 0xc820078780, 0x5c9cc8, 0x4, 0x10, 0x551820)
	/home/yacovm/OBC/go/src/runtime/hashmap_fast.go:307 +0x5b fp=0xc820038db8 sp=0xc820038d58
_/home/yacovm/go-logging/go-logging.(*moduleLeveled).IsEnabledFor(0xc8200981e0, 0x4, 0x5c9cc8, 0x4, 0x0)
	/home/yacovm/go-logging/go-logging/level.go:110 +0x62 fp=0xc820038e18 sp=0xc820038db8
_/home/yacovm/go-logging/go-logging.(*Logger).IsEnabledFor(0xc8200788a0, 0x4, 0x0)
	/home/yacovm/go-logging/go-logging/logger.go:140 +0x4d fp=0xc820038e48 sp=0xc820038e18
_/home/yacovm/go-logging/go-logging.(*Logger).log(0xc8200788a0, 0x4, 0x0, 0xc8200d9b30, 0x1, 0x1)
	/home/yacovm/go-logging/go-logging/logger.go:144 +0x2f fp=0xc820038eb8 sp=0xc820038e48
_/home/yacovm/go-logging/go-logging.(*Logger).Info(0xc8200788a0, 0xc8200d9b30, 0x1, 0x1)
	/home/yacovm/go-logging/go-logging/logger.go:239 +0x51 fp=0xc820038ef0 sp=0xc820038eb8
_/home/yacovm/go-logging/go-logging.TestConcurrency(0xc8200a0120)
	/home/yacovm/go-logging/go-logging/logger_test.go:73 +0x11f fp=0xc820038f68 sp=0xc820038ef0
testing.tRunner(0xc8200a0120, 0x6b8468)

I added a RWLock to protect the map and added a regression test that many times
fails without the locks
@yacovm yacovm mentioned this pull request Sep 30, 2016
billsegall added a commit to billsegall/aeron-go that referenced this pull request Dec 15, 2021
go-logging is unmaintained since 2016 and has significant reentrancy problems
causing crashes. See for example:
op/go-logging#75
op/go-logging#102
op/go-logging#105

To fix this we introduce a wrapper for a subset of the go-logging library
mapped on to Uber's zap logging library and switch to using that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant