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

Panic in recalculateFirstForSubj #4529

Closed
aldiesel opened this issue Sep 13, 2023 · 0 comments · Fixed by #4530
Closed

Panic in recalculateFirstForSubj #4529

aldiesel opened this issue Sep 13, 2023 · 0 comments · Fixed by #4530
Assignees
Labels
accepted The defect or proposal as been accepted bug Confirmed reproducible bug

Comments

@aldiesel
Copy link

What version were you using?

v2.9.22

What environment was the server running in?

Kubernetes/Linux

Is this defect reproducible?

I'm not sure how to reproduce this, but this out of bounds access may be related to the fix that was put in for this issue? #4445
8865c2a
Maybe this caused the out of bounds access

[1] 2023/09/13 15:35:12.278427 [DBG] JETSTREAM - JetStream connection closed: Client Closed
panic: runtime error: slice bounds out of range [-3785495:]

goroutine 30 [running]:
github.com/nats-io/nats-server/v2/server.(*msgBlock).recalculateFirstForSubj(0xc01d4b2680, {0xc023bedb80, 0x77}, 0xba431, 0xc0126d6500)
    github.com/nats-io/nats-server/v2/server/filestore.go:5979 +0x2ca
github.com/nats-io/nats-server/v2/server.(*fileStore).firstSeqForSubj(0xc00aa80580, {0xc023bedb80, 0x77})
    github.com/nats-io/nats-server/v2/server/filestore.go:2584 +0x1c6
github.com/nats-io/nats-server/v2/server.(*fileStore).storeRawMsg(0xc00aa80580, {0xc023bedb80, 0x77}, {0xc02339efc0, 0x205, 0x205}, {0xc01bfef8c0, 0x293, 0x293}, 0xc422b, ...)
    github.com/nats-io/nats-server/v2/server/filestore.go:2389 +0x675
github.com/nats-io/nats-server/v2/server.(*fileStore).StoreMsg(0xc00aa80580, {0xc023bedb80, 0x77}, {0xc02339efc0, 0x205, 0x205}, {0xc01bfef8c0, 0x293, 0x293})
    github.com/nats-io/nats-server/v2/server/filestore.go:2453 +0x155
github.com/nats-io/nats-server/v2/server.(*stream).processJetStreamMsg(0xc00a96ae00, {0xc023bedb80, 0x77}, {0xc27923c480, 0x14}, {0xc02339efc0, 0x205, 0x205}, {0xc01bfef8c0, 0x293, ...}, ...)
    github.com/nats-io/nats-server/v2/server/stream.go:4051 +0x1d1d
github.com/nats-io/nats-server/v2/server.(*stream).internalLoop(0xc00a96ae00)
    github.com/nats-io/nats-server/v2/server/stream.go:4474 +0x1025
created by github.com/nats-io/nats-server/v2/server.(*stream).setupSendCapabilities
    github.com/nats-io/nats-server/v2/server/stream.go:4353 +0x1bc
Stream closed EOF for redacted

Given the capability you are leveraging, describe your expectation?

N/A

Given the expectation, what is the defect you are observing?

The server panicked

@aldiesel aldiesel added the defect Suspected defect such as a bug or regression label Sep 13, 2023
@bruth bruth added accepted The defect or proposal as been accepted bug Confirmed reproducible bug and removed defect Suspected defect such as a bug or regression labels Sep 13, 2023
@derekcollison derekcollison self-assigned this Sep 13, 2023
derekcollison added a commit that referenced this issue Sep 13, 2023
… hold lock. (#4530)

This unprotected access allowed the cache to most likely be flushed and
after a subsequent writeMsgRecord would have the offset > slot value
which can't happen if lock is held due to us loading cache properly at
beginning of the function.

Signed-off-by: Derek Collison <derek@nats.io>

Resolves #4529
derekcollison added a commit that referenced this issue Sep 14, 2023
… hold lock. (#4531)

Cherry picked from main.

Fix for a call into mb.recalculateFirstForSubj() from
fs.recalculateFirstForSubj() that did not lock the mb properly.

Signed-off-by: Derek Collison <derek@nats.io>

Resolves #4529
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The defect or proposal as been accepted bug Confirmed reproducible bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants