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

zapx: Code indexer crashes gitea on i386/x86 with "panic: unaligned 64-bit atomic operation" #23617

Closed
sebastianertz opened this issue Mar 21, 2023 · 10 comments · Fixed by #24515
Labels
type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Milestone

Comments

@sebastianertz
Copy link

sebastianertz commented Mar 21, 2023

Description

On an i386 system gitea 1.18.5 runs perfectly.
Version 1.19.0 crashes when indexing code.
#22279 #23274 #22481 (comment)

zapx v15.3.9 fixes the problem
blevesearch/zapx@67addef

Gitea Version

1.19.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

panic: unaligned 64-bit atomic operation

goroutine 1508 [running]:
runtime/internal/atomic.panicUnaligned()
	/usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Xadd64(0x127aa03c, 0x4a)
	/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.8/contentcoder.go:114
github.com/blevesearch/zapx/v15.(*chunkedContentCoder).flushContents(0x127aa000)
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/contentcoder.go:143 +0x2fe
github.com/blevesearch/zapx/v15.(*chunkedContentCoder).Close(...)
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/contentcoder.go:110
github.com/blevesearch/zapx/v15.(*interim).writeDicts(0x110bf0e0)
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/new.go:803 +0x150f
github.com/blevesearch/zapx/v15.(*interim).convert(0x110bf0e0)
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/new.go:277 +0x2ff
github.com/blevesearch/zapx/v15.(*ZapPlugin).newWithChunkMode(0xd839e74, {0x116be100, 0x10, 0x10}, 0x402)
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/new.go:72 +0x18b
github.com/blevesearch/zapx/v15.(*ZapPlugin).New(0xd839e74, {0x116be100, 0x10, 0x10})
	/go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.8/new.go:47 +0x43
github.com/blevesearch/bleve/v2/index/scorch.(*Scorch).Batch(0xed76c00, 0xf952380)
	/go/pkg/mod/github.com/blevesearch/bleve/v2@v2.3.6/index/scorch/scorch.go:412 +0x5fe
github.com/blevesearch/bleve/v2.(*indexImpl).Batch(0x12076460, 0xf98eb80)
	/go/pkg/mod/github.com/blevesearch/bleve/v2@v2.3.6/index_impl.go:310 +0xa0
code.gitea.io/gitea/modules/indexer/bleve.(*FlushingBatch).Flush(0x126edd5c)
	/source/modules/indexer/bleve/batch.go:52 +0x32
code.gitea.io/gitea/modules/indexer/bleve.(*FlushingBatch).flushIfFull(0x11c49d5c)
	/source/modules/indexer/bleve/batch.go:47 +0x5a
code.gitea.io/gitea/modules/indexer/bleve.(*FlushingBatch).Index(0x11c49d5c, {0x11381ed8, 0x13}, {0xa4ab980, 0x113b1ac0})
	/source/modules/indexer/bleve/batch.go:34 +0x6c
code.gitea.io/gitea/modules/indexer/code.(*BleveIndexer).addUpdate(0xfe7ff10, {0xbecb1cc, 0xed69970}, {0xbec9fd0, 0x104791a0}, 0x1047a990, {0xf1bfc00, 0x28}, {{0x1047eb10, 0x10}, ...}, ...)
	/source/modules/indexer/code/bleve.go:231 +0x606
code.gitea.io/gitea/modules/indexer/code.(*BleveIndexer).Index(0xfe7ff10, {0xbecb1cc, 0xed69970}, 0x1018bb00, {0xf1bfc00, 0x28}, 0x10580600)
	/source/modules/indexer/code/bleve.go:300 +0x3f4
code.gitea.io/gitea/modules/indexer/code.(*wrappedIndexer).Index(0xfb3ab70, {0xbecb1cc, 0xed69970}, 0x1018bb00, {0xf1bfc00, 0x28}, 0x10580600)
	/source/modules/indexer/code/wrapped.go:84 +0x7d
code.gitea.io/gitea/modules/indexer/code.index({0xbecb1cc, 0xed69970}, {0xbece788, 0xfb3ab70}, 0x8d)
	/source/modules/indexer/code/indexer.go:106 +0x148
code.gitea.io/gitea/modules/indexer/code.Init.func2({0xf9faa00, 0x14, 0x14})
	/source/modules/indexer/code/indexer.go:156 +0x1e2
code.gitea.io/gitea/modules/queue.NewByteFIFOUniqueQueue.func1({0xf9faa00, 0x14, 0x14})
	/source/modules/queue/queue_bytefifo.go:398 +0x3e
code.gitea.io/gitea/modules/queue.(*WorkerPool).doWork(0x12074180, {0xbecb2cc, 0xf98e300})
	/source/modules/queue/workerpool.go:593 +0xa04
code.gitea.io/gitea/modules/queue.(*WorkerPool).addWorkers.func1()
	/source/modules/queue/workerpool.go:311 +0x5d
created by code.gitea.io/gitea/modules/queue.(*WorkerPool).addWorkers
	/source/modules/queue/workerpool.go:309 +0x25

Git Version

No response

Operating System

No response

How are you running Gitea?

Self hosted, binary from https://dl.gitea.org/gitea/1.19.0/

Database

None

@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 21, 2023

Didn't you fix that @zeripath?

@zeripath
Copy link
Contributor

I tried...

Looks like we need to debackport the other fix.

@lunny
Copy link
Member

lunny commented Mar 22, 2023

Don't know why our CI didn't catch that problem. Oh, that's a runtime problem but CI just tests to compile it.

@bugreport0
Copy link
Contributor

Can confirm this also happens with gitea-1.19.0-linux-arm-6 on Raspberry Pi.

Gitea v1.19 starts up, then quickly crashes with panic: unaligned 64-bit atomic operation in the zapx thing.

@lunny lunny added the type/upstream This is an issue in one of Gitea's dependencies and should be reported there label Mar 29, 2023
@wolfogre
Copy link
Member

Also found it when helping others.

image

@wolfogre
Copy link
Member

And I noticed that the fix is for v15.3.6

gitea/go.mod

Line 289 in 704f3aa

replace github.com/blevesearch/zapx/v15 v15.3.6 => github.com/zeripath/zapx/v15 v15.3.6-alignment-fix

But the panic comes from v15.3.8 now, which is updated by #22410

@RubenPX
Copy link

RubenPX commented Apr 18, 2023

Still crashing

imagen

imagen

@jkoan
Copy link

jkoan commented May 2, 2023

@zeripath, @KN4CK3R Didn't OP already told that the solution is fixed in zapx v15.3.9 blevesearch/zapx@67addef ? So only a dependency update is needed?

@bugreport0
Copy link
Contributor

My Gitea instance has been broken for over a month now and I'd love to use it again. Is there a way to help test or develop a fix for 1.19.x?

@wolfogre
Copy link
Member

wolfogre commented May 4, 2023

github.com/blevesearch/zapx/v15 has been upgraded tov15.3.9 in #23062, so it should fix this issue.

Maybe we should backport it to v1.19?

@lunny lunny added this to the 1.19.4 milestone May 4, 2023
silverwind pushed a commit that referenced this issue May 4, 2023
Fix #23617

Co-authored-by: Giteabot <teabot@gitea.io>
KN4CK3R pushed a commit that referenced this issue May 4, 2023
Backport #23062
Backport #24515
Fix #23617 

This notably brings support for GOARCH=loong64, among other fixes.
This PR also fix bleve search architecture problem.

---------

Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
Co-authored-by: WÁNG Xuěruì <1175567+xen0n@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/bug type/upstream This is an issue in one of Gitea's dependencies and should be reported there
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants