Skip to content

panic log for some http API with negative table id #52012

@lcwangchao

Description

@lcwangchao

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

> curl "http://127.0.0.1:10080/db-table/-123"

2. What did you expect to see? (Required)

> curl "http://127.0.0.1:10080/db-table/-123"
[schema:1146]Table which ID = -123 does not exist.

3. What did you see instead (Required)

> curl "http://127.0.0.1:10081/db-table/-123"
curl: (52) Empty reply from server

And a panic log in tidb

2024/03/22 10:42:52 http: panic serving 127.0.0.1:53256: runtime error: index out of range [-123]
goroutine 5202 [running]:
net/http.(*conn).serve.func1()
        /Users/wangchao/.gvm/gos/go1.21.0/src/net/http/server.go:1868 +0x118
panic({0x1081c98c0?, 0x140189ca198?})
        /Users/wangchao/.gvm/gos/go1.21.0/src/runtime/panic.go:920 +0x254
github.com/pingcap/tidb/pkg/infoschema.(*infoSchema).TableByID(0x140059bba00, 0xffffffffffffff85)
        /Users/wangchao/Code/pingcap/tidb/pkg/infoschema/infoschema.go:235 +0xfc
github.com/pingcap/tidb/pkg/server/handler/tikvhandler.DBTableHandler.ServeHTTP({0x1401179e5d0}, {0x10850bac0, 0x140189b6000}, 0x14017be9c00)
        /Users/wangchao/Code/pingcap/tidb/pkg/server/handler/tikvhandler/tikv_handler.go:1805 +0x238
github.com/gorilla/mux.(*Router).ServeHTTP(0x1401142cf00, {0x10850bac0, 0x140189b6000}, 0x14017be9c00)
        /Users/wangchao/.gvm/pkgsets/go1.21.0/global/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0x254
net/http.(*ServeMux).ServeHTTP(0x140118b5900, {0x10850bac0, 0x140189b6000}, 0x14017be9a00)
        /Users/wangchao/.gvm/gos/go1.21.0/src/net/http/server.go:2514 +0x160
github.com/pingcap/tidb/pkg/server/internal/util.CorsHandler.ServeHTTP({{0x1084ed0e0, 0x140118b5900}, 0x140007de900}, {0x10850bac0, 0x140189b6000}, 0x14017be9a00)
        /Users/wangchao/Code/pingcap/tidb/pkg/server/internal/util/util.go:219 +0xe0
net/http.serverHandler.ServeHTTP({0x1401142f1d0}, {0x10850bac0, 0x140189b6000}, 0x14017be9a00)
        /Users/wangchao/.gvm/gos/go1.21.0/src/net/http/server.go:2938 +0x2a0
net/http.(*conn).serve(0x140189a4000, {0x108520c18, 0x140189a6050})
        /Users/wangchao/.gvm/gos/go1.21.0/src/net/http/server.go:2009 +0x155c
created by net/http.(*Server).Serve in goroutine 573
        /Users/wangchao/.gvm/gos/go1.21.0/src/net/http/server.go:3086 +0x7f8

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions