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

Gitea crashes with "unaligned 64-bit atomic operation" #19518

Closed
abutre opened this issue Apr 26, 2022 · 4 comments · Fixed by #19531
Closed

Gitea crashes with "unaligned 64-bit atomic operation" #19518

abutre opened this issue Apr 26, 2022 · 4 comments · Fixed by #19531
Labels

Comments

@abutre
Copy link

abutre commented Apr 26, 2022

Description

Gitea master version crashes on arm v6 with "unaligned 64-bit atomic operation

Gitea Version

master

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/abutre/03b3b7e833e4a5f2cc18bbb103dd335d

Screenshots

No response

Git Version

2.32.0

Operating System

Ubuntu 21.10 on arm v6

How are you running Gitea?

Self hosted

Database

SQLite

@Gusted
Copy link
Contributor

Gusted commented Apr 26, 2022

Could you try to apply this patch and see if that fixes the issue?

diff --git a/modules/queue/workerpool.go b/modules/queue/workerpool.go
index 2d8504598..8e0b5f532 100644
--- a/modules/queue/workerpool.go
+++ b/modules/queue/workerpool.go
@@ -22,6 +22,7 @@ import (
 // they use to detect if there is a block and will grow and shrink in
 // response to demand as per configuration.
 type WorkerPool struct {
+       numInQueue         int64
        lock               sync.Mutex
        baseCtx            context.Context
        baseCtxCancel      context.CancelFunc
@@ -38,7 +39,6 @@ type WorkerPool struct {
        blockTimeout       time.Duration
        boostTimeout       time.Duration
        boostWorkers       int
-       numInQueue         int64
 }
 
 var (

The problem is caused that we're trying to do 64-bit operations on 32-bit machine(Armv6), moving it to the begin of the struct should allow the atomic operation to work, this "workaround" is noted at the atomic's BUG section https://pkg.go.dev/sync/atomic#pkg-note-BUG

@abutre
Copy link
Author

abutre commented Apr 27, 2022

Running without any issue with the suggested change.

Gusted pushed a commit to Gusted/gitea that referenced this issue Apr 27, 2022
- Doing 64-bit atomic operations on 32-bit machines is a bit tricky by
golang, as they can only be done under certain set of
conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
- This PR fixes such case whereby the conditions weren't met, it moves
the int64 to the first field of the struct, which will 64-bit operations
happening on this property on 32-bit machines.
- Resolves go-gitea#19518
Gusted pushed a commit to Gusted/gitea that referenced this issue Apr 27, 2022
- Backport go-gitea#19531
  - Doing 64-bit atomic operations on 32-bit machines is a bit tricky by golang, as they can only be done under certain set of conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
  - This PR fixes such case whereby the conditions weren't met, it moves the int64 to the first field of the struct, which will 64-bit operations happening on this property on 32-bit machines.
  - Resolves go-gitea#19518
jolheiser pushed a commit that referenced this issue Apr 27, 2022
- Doing 64-bit atomic operations on 32-bit machines is a bit tricky by
golang, as they can only be done under certain set of
conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
- This PR fixes such case whereby the conditions weren't met, it moves
the int64 to the first field of the struct, which will 64-bit operations
happening on this property on 32-bit machines.
- Resolves #19518
jolheiser pushed a commit that referenced this issue Apr 27, 2022
- Backport #19531
  - Doing 64-bit atomic operations on 32-bit machines is a bit tricky by golang, as they can only be done under certain set of conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
  - This PR fixes such case whereby the conditions weren't met, it moves the int64 to the first field of the struct, which will 64-bit operations happening on this property on 32-bit machines.
  - Resolves #19518
Codeberg-org pushed a commit to Codeberg-org/gitea that referenced this issue Apr 28, 2022
…gitea#19532)

- Backport go-gitea#19531
  - Doing 64-bit atomic operations on 32-bit machines is a bit tricky by golang, as they can only be done under certain set of conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
  - This PR fixes such case whereby the conditions weren't met, it moves the int64 to the first field of the struct, which will 64-bit operations happening on this property on 32-bit machines.
  - Resolves go-gitea#19518
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 24, 2022
- Doing 64-bit atomic operations on 32-bit machines is a bit tricky by
golang, as they can only be done under certain set of
conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
- This PR fixes such case whereby the conditions weren't met, it moves
the int64 to the first field of the struct, which will 64-bit operations
happening on this property on 32-bit machines.
- Resolves go-gitea#19518
@sebastianertz
Copy link

sebastianertz commented Nov 27, 2022

On an i386 system gitea 1.17.3 runs perfectly.
Version 1.18.0-rc0 and 1.18.0-rc1 crashes when indexing code.

panic: unaligned 64-bit atomic operation

goroutine 2044 [running]:
runtime/internal/atomic.panicUnaligned()
        /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Xadd64(0xf9ede74, 0x3b)
        /usr/local/go/src/runtime/internal/atomic/atomic_386.s:125 +0x11
github.com/blevesearch/zapx/v15.(*chunkedContentCoder).incrementBytesWritten(...)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/contentcoder.go:114
github.com/blevesearch/zapx/v15.(*chunkedContentCoder).flushContents(0xf9ede00)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/contentcoder.go:143 +0x24a
github.com/blevesearch/zapx/v15.(*chunkedContentCoder).Close(...)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/contentcoder.go:110
github.com/blevesearch/zapx/v15.(*interim).writeDicts(0xe334a50)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:803 +0x1443
github.com/blevesearch/zapx/v15.(*interim).convert(0xe334a50)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:277 +0x2b5
github.com/blevesearch/zapx/v15.(*ZapPlugin).newWithChunkMode(0xd1bbf88, {0xe434ac0, 0x8, 0x8}, 0x402)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:72 +0x18b
github.com/blevesearch/zapx/v15.(*ZapPlugin).New(0xd1bbf88, {0xe434ac0, 0x8, 0x8})
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:47 +0x43
github.com/blevesearch/bleve/v2/index/scorch.(*Scorch).Batch(0x10dfa000, 0xf5459c0)
        /go/pkg/mod/github.com/blevesearch/bleve/v2@v2.3.4/index/scorch/scorch.go:411 +0x5ff
github.com/blevesearch/bleve/v2.(*indexImpl).Batch(0x10de1720, 0x10e15060)
        /go/pkg/mod/github.com/blevesearch/bleve/v2@v2.3.4/index_impl.go:309 +0xa0
code.gitea.io/gitea/modules/indexer/bleve.(*FlushingBatch).Flush(0xf861da0)
        /source/modules/indexer/bleve/batch.go:53 +0x32
code.gitea.io/gitea/modules/indexer/code.(*BleveIndexer).Index(0xe64df10, {0xba44760, 0xe666740}, 0xe31cd80, {0x12299400, 0x28}, 0xfb440a8)
        /source/modules/indexer/code/bleve.go:311 +0x407
code.gitea.io/gitea/modules/indexer/code.(*wrappedIndexer).Index(0xe82a570, {0xba44760, 0xe666740}, 0xe31cd80, {0x12299400, 0x28}, 0xfb440a8)
        /source/modules/indexer/code/wrapped.go:85 +0x7d
code.gitea.io/gitea/modules/indexer/code.index({0xba44760, 0xe666740}, {0xba476ec, 0xe82a570}, 0x81)
        /source/modules/indexer/code/indexer.go:107 +0x11f
code.gitea.io/gitea/modules/indexer/code.Init.func2({0xf37c6e0, 0x1, 0x14})
        /source/modules/indexer/code/indexer.go:157 +0x1e0
code.gitea.io/gitea/modules/queue.NewByteFIFOUniqueQueue.func1({0xf37c6e0, 0x1, 0x14})
        /source/modules/queue/queue_bytefifo.go:399 +0x3e
code.gitea.io/gitea/modules/queue.(*WorkerPool).doWork(0x10e61080, {0xba44820, 0xe3fcbc0})
        /source/modules/queue/workerpool.go:564 +0x69f
code.gitea.io/gitea/modules/queue.(*WorkerPool).addWorkers.func1()
        /source/modules/queue/workerpool.go:312 +0x5d
created by code.gitea.io/gitea/modules/queue.(*WorkerPool).addWorkers
        /source/modules/queue/workerpool.go:310 +0x25

@lunny
Copy link
Member

lunny commented Nov 27, 2022

please file a new issue

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants