diff --git a/pkg/handler/body_reader.go b/pkg/handler/body_reader.go index 6ca7a0f44..8f8d2e3f7 100644 --- a/pkg/handler/body_reader.go +++ b/pkg/handler/body_reader.go @@ -19,10 +19,16 @@ import ( // the error but this can instead be done in the handler. // In addition, the bodyReader keeps track of how many bytes were read. type bodyReader struct { + // bytesCounter is the first field to ensure that its properly aligned, + // otherwise we run into alignment issues on some 32-bit builds. + // See https://github.com/tus/tusd/issues/1047 + // See https://pkg.go.dev/sync/atomic#pkg-note-BUG + // TODO: In the future we should move all of these values to the safe + // atomic.Uint64 type, which takes care of alignment automatically. + bytesCounter int64 ctx *httpContext reader io.ReadCloser err error - bytesCounter int64 onReadDone func() }