-
Notifications
You must be signed in to change notification settings - Fork 44
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
flac.Parse funcs are prone to data races #56
Comments
Use function local backing array instead. As the size of the function local backing array is known at compile time, hopefully it can be allocated on the stack, to avoid heap allocations. This issue was identified by @zachorosz. Fixes #56.
Hej Zach! Happy to hear you like the library : )
Definitely helpful that you dug up the commit which introduced the race condition. Thanks! PR #57 should resolve this. Could you check if #57 is enough to resolve your race conditions? Cheers, |
Thank you @mewmew! Pulled the branch and can confirm it works as expected! |
* meta: fix data race caused by global buffer Use function local backing array instead. As the size of the function local backing array is known at compile time, hopefully it can be allocated on the stack, to avoid heap allocations. This issue was identified by @zachorosz. Fixes #56. * flac: update dependencies, run `go get -u ./...` * readme: add release notes for v1.0.8 Issues identified: - @ktmf01 (issue encoding 8-bps WAV audio samples) - @zachorosz (race condition when reading meta data) - @karlek (incorrect variable used for metadata block type in error string)
Hello! Thanks for the wonderful library!
I'm trying to Parse multiple .flac files concurrently where each file is being parsed by its own goroutine (not multiple goroutines parsing 1 file). Getting some flakey results because
readBytes
func uses a global buffer and is prone to data races.Is there any harm not using this global buffer? Could make a slice of size n in the func itself - would allocate it on the stack up until a certain size I think.
This is the commit that introduced this: e03baec (I know it's pretty old :/ )
The text was updated successfully, but these errors were encountered: