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

Swagger API makes server to fail on panic #21869

Closed
VitSimon opened this issue Nov 19, 2022 · 8 comments
Closed

Swagger API makes server to fail on panic #21869

VitSimon opened this issue Nov 19, 2022 · 8 comments
Labels

Comments

@VitSimon
Copy link

VitSimon commented Nov 19, 2022

Description

When I use swagger page call:
http://localhost:3000/api/swagger#/issue/issueCreateIssue

operation is successful but server is terminated on panic.

JSONInput.txt
CLIOutput.txt

Logs

2022/11/19 11:47:46 ...s/graceful/server.go:62:NewServer() [I] [6378b452-46] Starting new Web server: tcp:0.0.0.0:3000 on PID: 1300
2022/11/19 11:47:58 router: completed POST /api/v1/repos/admin1/GRPCBlueprint/issues for 127.0.0.1:64688, 201 Created in 65.6ms @ repo/issue.go:562(repo.CreateIssue)
panic: unaligned 64-bit atomic operation

goroutine 1098 [running]:
runtime/internal/atomic.panicUnaligned()
        /usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Xadd64(0x1d210df4, 0x8)
        /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(0x1d210d80)
        /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(0x1f7c0f00)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:803 +0x1443
github.com/blevesearch/zapx/v15.(*interim).convert(0x1f7c0f00)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:277 +0x2b5
github.com/blevesearch/zapx/v15.(*ZapPlugin).newWithChunkMode(0x5b887a4, {0x1e00d7a8, 0x1, 0x1}, 0x402)
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:72 +0x18b
github.com/blevesearch/zapx/v15.(*ZapPlugin).New(0x5b887a4, {0x1e00d7a8, 0x1, 0x1})
        /go/pkg/mod/github.com/blevesearch/zapx/v15@v15.3.5/new.go:47 +0x43
github.com/blevesearch/bleve/v2/index/scorch.(*Scorch).Batch(0x1c937000, 0x1f7dea70)
        /go/pkg/mod/github.com/blevesearch/bleve/v2@v2.3.4/index/scorch/scorch.go:411 +0x5ff
github.com/blevesearch/bleve/v2.(*indexImpl).Batch(0x1bb045a0, 0x1e715d40)
        /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(0x1adf1dc4)
        /source/modules/indexer/bleve/batch.go:53 +0x32
code.gitea.io/gitea/modules/indexer/issues.(*BleveIndexer).Index(0x1be45720, {0x1e00d6f0, 0x1, 0x1})
        /source/modules/indexer/issues/bleve.go:226 +0x183
code.gitea.io/gitea/modules/indexer/issues.InitIssueIndexer.func1({0x1b942640, 0x1, 0x14})
        /source/modules/indexer/issues/indexer.go:147 +0x5b1
code.gitea.io/gitea/modules/queue.NewByteFIFOQueue.func1({0x1b942640, 0x1, 0x14})
        /source/modules/queue/queue_bytefifo.go:71 +0x3e
code.gitea.io/gitea/modules/queue.(*WorkerPool).doWork(0x1d4f85a0, {0x45bdc20, 0x1d573540})
        /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

Gitea Version

1.18.0+rc0-23-gaf8b2250c

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

I cannot verify it on web site.

Git Version

git version 2.33.0.windows.2

Operating System

Microsoft Windows [Version 10.0.19044.2251]

How are you running Gitea?

Gitea downloaded from here:
https://dl.gitea.io/gitea/1.18

run via cmd command in console.

Database

SQLite

@VitSimon
Copy link
Author

I am starting it without admin rights elevation

@yardenshoham
Copy link
Member

Does your executable's architecture match your own?

@wxiaoguang
Copy link
Contributor

It could be a bug in blevesearch for 32bit code.

Golang i386 code can not do atomic operations on unaligned 64bit fields.

So, use 64bit (amd64) release and everything will be fine.

@zeripath
Copy link
Contributor

zeripath commented Nov 19, 2022

Looking at the logs we see a panic due to an unaligned atomic.

So I think we need to know a bit more about your architecture. As @yardenshoham says are you running the correct version for your architecture?

If so, if we look at https://github.com/blevesearch/zapx/blame/master/contentcoder.go. We see this:

type chunkedContentCoder struct {
	final     []byte
	chunkSize uint64
	currChunk uint64
	chunkLens []uint64

	w                io.Writer
	progressiveWrite bool

	chunkMetaBuf bytes.Buffer
	chunkBuf     bytes.Buffer

	chunkMeta []MetaData

	compressed []byte // temp buf for snappy compression

	// atomic access to this variable
	bytesWritten uint64
}

Now the bytesWritten here is used as an atomic, but if we look at the rest of the fields in the struct there's a bool and 2 bytes.Buffer above it. Which I could imagine might cause it to be misaligned.

If you're definitely using the correct architecture then this would constitute a bug in https://github.com/blevesearch/zapx/

@zeripath
Copy link
Contributor

See: blevesearch/zapx#147

@VitSimon
Copy link
Author

Hi, thanks.

I am using gitea-1.18-gogit-windows-4.0-386. I will try amd64 then. I think I have 64bit system. Then I will pass my result here.

@VitSimon
Copy link
Author

@wxiaoguang , @zeripath , @yardenshoham :

I have downloaded amd64 package and tried the same action several times on previously existing database.
Behavior I have reported doesn't appears any more. Thanks again.

@VitSimon
Copy link
Author

configuration problem on my side.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants