Skip to content

Commit 67addef

Browse files
authored
Fixed 64-bit alignment panic in chunkedContentCoder on 32-bit platforms. (#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]>
1 parent e34dce0 commit 67addef

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contentcoder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var (
3737
)
3838

3939
type chunkedContentCoder struct {
40+
bytesWritten uint64 // atomic access to this variable, moved to top to correct alignment issues on ARM, 386 and 32-bit MIPS.
41+
4042
final []byte
4143
chunkSize uint64
4244
currChunk uint64
@@ -45,7 +47,6 @@ type chunkedContentCoder struct {
4547
compressed []byte // temp buf for snappy compression
4648

4749
w io.Writer
48-
bytesWritten uint64 // atomic access to this variable
4950
progressiveWrite bool
5051

5152
chunkMeta []MetaData

0 commit comments

Comments
 (0)