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

Data Race when SetReportCaller is true #914

Closed
georlav opened this issue Mar 4, 2019 · 0 comments
Closed

Data Race when SetReportCaller is true #914

georlav opened this issue Mar 4, 2019 · 0 comments

Comments

@georlav
Copy link
Contributor

georlav commented Mar 4, 2019

func TestSetReportCallerRace(t *testing.T) {
	l := New()
	l.Out = ioutil.Discard
	l.SetReportCaller(true)

	var wg sync.WaitGroup
	wg.Add(100)

	for i := 0; i < 100; i++ {
		go func() {
			l.Error("Some Error")
			wg.Done()
		}()
	}

	wg.Wait()
}

WARNING: DATA RACE
Read at 0x000000c75b98 by goroutine 14:
github.com/sirupsen/logrus.getCaller()
/home/georlav/other/logrus/entry.go:161 +0x7b
github.com/sirupsen/logrus.Entry.log()
/home/georlav/other/logrus/entry.go:210 +0x395
github.com/sirupsen/logrus.(*Entry).Log()
/home/georlav/other/logrus/entry.go:258 +0x154
github.com/sirupsen/logrus.(*Logger).Log()
/home/georlav/other/logrus/logger.go:184 +0xa4
github.com/sirupsen/logrus_test.TestSetReportCallerRace.func1()
/home/georlav/other/logrus/logger.go:216 +0x81

Previous write at 0x000000c75b98 by goroutine 7:
github.com/sirupsen/logrus.getCaller.func1()
/home/georlav/other/logrus/entry.go:170 +0xe1
sync.(*Once).Do()
/snap/go/3318/src/sync/once.go:44 +0xde
github.com/sirupsen/logrus.getCaller()
/home/georlav/other/logrus/entry.go:165 +0x149
github.com/sirupsen/logrus.Entry.log()
/home/georlav/other/logrus/entry.go:210 +0x395
github.com/sirupsen/logrus.(*Entry).Log()
/home/georlav/other/logrus/entry.go:258 +0x154
github.com/sirupsen/logrus.(*Logger).Log()
/home/georlav/other/logrus/logger.go:184 +0xa4
github.com/sirupsen/logrus_test.TestSetReportCallerRace.func1()
/home/georlav/other/logrus/logger.go:216 +0x81

@georlav georlav changed the title Data Race when SetReportCaller is true on parallel execution Data Race when SetReportCaller is true Mar 4, 2019
@dgsb dgsb mentioned this issue Mar 6, 2019
@dgsb dgsb closed this as completed Mar 6, 2019
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

No branches or pull requests

2 participants