-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix alignment in chunkedContentCoder #147
Fix alignment in chunkedContentCoder #147
Conversation
An unaligned atomic bug was unfortunately introduced in #119 because the `bytesWritten` field was placed at the end of the `chunkedContentCoder` struct. This places this after the bytes.Buffers and the bool causing it to be misaligned. The ideal placement of this variable is not entirely clear but placing it before the progresiveWrite bool should help. An alternative would be to just place this atomic field at the top of the struct then there would be no risk of it becoming misaligned in future. I moved a few things around to reduce the size of the struct too but it could be possible to adjust things a little more to make the struct a little smaller. Signed-off-by: Andrew Thornton <[email protected]>
Thanks you very much @zeripath for raising this bug. I'm not entirely sure about the specifics of the bug over here. However, it looks like the panic message that the user has posted in the issue go-gitea/gitea#21869 shows that the atomic.AddUint64() is the cause of panic.
Now, I also observe that the version of the zapx and bleve used is 15.3.5 and 2.3.4 respectively.
These releases had the atomic operations in incrementBytesWritten method (which is why I'm assuming its failing). The upcoming release of bleve (2.3.6) will have the zapx tag 15.3.7 which avoids the atomic operations altogether. My thinking is that this issue won't occur when you use 2.3.6. However, if the issue still persists in that release, please go ahead create an issue or a PR (if you've verified a fix for the same) and add me as a reviewer for it. Thank you! |
There is an unaligned atomic field in zapx 15.3.5 which should have been fixed in blevesearch/zapx#147 This bug causes issues on 32bit builds. Update bleve and zapx to account for this. Fix go-gitea#21957 Signed-off-by: Andrew Thornton <[email protected]>
Following the fix in blevesearch#147, a 'panic: unaligned 64-bit atomic operation' is still occurring on some platforms. As noted in blevesearch#147, this commit implements the alternative fix by placing the bytesWritten field at the top of the struct. Per the Golang sync/atomic documentation, on ARM, 386 and 32-bit MIPS systems, this is the reliable way to prevent these issues. Signed-off-by: Callum Jones <[email protected]>
Following the fix in blevesearch#147, a 'panic: unaligned 64-bit atomic operation' is still occurring on some platforms. As noted in blevesearch#147, this commit implements the alternative fix by placing the bytesWritten field at the top of the struct. Per the Golang sync/atomic documentation, on ARM, 386 and 32-bit MIPS systems, this is the reliable way to prevent these issues. Signed-off-by: Callum Jones <[email protected]>
…ms. (#148) Following the fix in #147, a 'panic: unaligned 64-bit atomic operation' is still occurring on some platforms. As noted in #147, this commit implements the alternative fix by placing the bytesWritten field at the top of the struct. Per the Golang sync/atomic documentation, on ARM, 386 and 32-bit MIPS systems, this is the reliable way to prevent these issues. Signed-off-by: Callum Jones <[email protected]>
An unaligned atomic bug was unfortunately introduced in #119 because the
bytesWritten
field was placed at the end of thechunkedContentCoder
struct.This places this after the bytes.Buffers and the bool causing it to be misaligned.
The ideal placement of this variable is not entirely clear but placing it before the progresiveWrite bool should help.
An alternative would be to just place this atomic field at the top of the struct then there would be no risk of it becoming misaligned in future.
I moved a few things around to reduce the size of the struct too but it could be possible to adjust things a little more to make the struct a little smaller.
Signed-off-by: Andrew Thornton [email protected]