jackc / jackc/chunkreader

a panic due to slice out of range

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
15
Forks
8
PR merge metrics
No merged PRs in 30d

Description

```
panic: runtime error: slice bounds out of range [5:2]

goroutine 1 [running]:
github.com/jackc/chunkreader/v2.(*ChunkReader).Next(0xc0001de400, 0xfffffffffffffffd, 0xc000150000, 0x5, 0x2000, 0x0, 0x0)
/go/pkg/mod/github.com/jackc/chunkreader/v2@v2.0.1/chunkreader.go:61 +0x452
github.com/jackc/pgproto3/v2.(*Frontend).Receive(0xc000555400, 0x5a, 0xc0004f3f00, 0x77, 0x77)
/go/pkg/mod/github.com/jackc/pgproto3/v2@v2.1.1/frontend.go:82 +0x63
github.com/jackc/pgconn.(*PgConn).peekMessage(0xc00083a000, 0x0, 0x0, 0xfffffffe000ce400, 0x0)
/go/pkg/mod/github.com/jackc/pgconn@v1.9.0/pgconn.go:463 +0x346
github.com/jackc/pgconn.(*PgConn).receiveMessage(0xc00083a000, 0xc0000ce400, 0x5a, 0x400, 0x5a)
/go/pkg/mod/github.com/jackc/pgconn@v1.9.0/pgconn.go:485 +0x45
github.com/jackc/pgconn.connect(0x1b08c40, 0xc00004e060, 0xc0008460f0, 0xc000114ba0, 0x0, 0x0, 0x0)
/go/pkg/mod/github.com/jackc/pgconn@v1.9.0/pgconn.go:268 +0x6ee
github.com/jackc/pgconn.ConnectConfig(0x1b08c40, 0xc00004e060, 0xc0008460f0, 0x0, 0x0, 0x0)
/go/pkg/mod/github.com/jackc/pgconn@v1.9.0/pgconn.go:150 +0x2a5
github.com/jackc/pgx/v4.connect(0x1b08c40, 0xc00004e060, 0xc000846000, 0x0, 0x0, 0x406ffa)
/go/pkg/mod/github.com/jackc/pgx/v4@v4.12.0/conn.go:222 +0x16b
github.com/jackc/pgx/v4.ConnectConfig(...)
/go/pkg/mod/github.com/jackc/pgx/v4@v4.12.0/conn.go:113
....
Our redacted stuff
....
main.main()
/go/src/workdir/autogen/cmd/batch-jobs-api-v2-server/main.go:51 +0x4b4
```

It has happened in production during time when the db was not accessible due to maintenance restart, sorry that I do not have more details but this is slice out of bounds you could just check if the index is in length

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by inspecting chunkreader.go:61 and the call path through pgproto3 Frontend.Receive and pgconn connection setup shown in the stack trace. Reproduce the reported database-unavailable condition if possible, then verify that the connection attempt no longer panics on invalid slice bounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.