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 index out of range in routers/web/repo/actions/view.go #24458

Closed
harryzcy opened this issue May 1, 2023 · 6 comments · Fixed by #24516
Closed

Panic index out of range in routers/web/repo/actions/view.go #24458

harryzcy opened this issue May 1, 2023 · 6 comments · Fixed by #24516
Labels
topic/gitea-actions related to the actions of Gitea type/bug

Comments

@harryzcy
Copy link
Contributor

harryzcy commented May 1, 2023

Description

Panic happened. Maybe need investigating.

2023/05/01 04:44:56 [644f43c8-10] router: completed POST /api/actions/runner.v1.RunnerService/UpdateTask for 10.42.1.205:44104, 200 OK in 105.0ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2023/05/01 04:44:57 [644f43c9-2] router: completed POST /api/actions/runner.v1.RunnerService/FetchTask for 10.42.2.155:41880, 200 OK in 72.9ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2023/05/01 04:44:57 routers/web/base.go:134:1() [E] [644f43c9] PANIC: runtime error: index out of range [427] with length 427
        /usr/local/go/src/runtime/panic.go:113 (0x43cec7)
        /go/src/code.gitea.io/gitea/routers/web/repo/actions/view.go:164 (0x20bda9f)
        /go/src/code.gitea.io/gitea/modules/web/wrap_convert.go:46 (0x1df89cf)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:40 (0x1df6ff7)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x1601fab)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:62 (0x1df7407)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:62 (0x1df7407)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:62 (0x1df7407)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/middleware/get_head.go:37 (0x1f7535f)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:62 (0x1df7407)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/context/context.go:821 (0x19e74a3)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:73 (0x15fff6b)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:316 (0x16017b3)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x1601fab)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/routers/web/base.go:174 (0x20c5ac3)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20221220005550-e056dc379164/session.go:257 (0x1544a23)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/wrap.go:109 (0x1df7d4f)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:73 (0x15fff6b)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:316 (0x16017b3)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:444 (0x1601fab)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/routers/common/middleware.go:80 (0x1f04547)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:122 (0x1df3133)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/routers/common/middleware.go:112 (0x1f0347f)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x1f0219b)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/src/code.gitea.io/gitea/routers/common/middleware.go:32 (0x1f043c3)
        /usr/local/go/src/net/http/server.go:2122 (0x920827)
        /go/pkg/mod/github.com/go-chi/chi/v5@v5.0.8/mux.go:90 (0x15fff27)
        /go/src/code.gitea.io/gitea/modules/web/route.go:191 (0x1df657f)
        /usr/local/go/src/net/http/server.go:2936 (0x92385f)
        /usr/local/go/src/net/http/server.go:1995 (0x91f637)
        /usr/local/go/src/runtime/asm_arm64.s:1172 (0x475143)

2023/05/01 04:44:57 routers/web/base.go:169:1() [E] [644f43c9] template: base/head_navbar:155:7: executing "base/head_navbar" at <avatar $.Context .SignedUser 24 "tiny">: error calling avatar: runtime error: invalid memory address or nil pointer dereference
2023/05/01 04:44:57 [644f43c9] router: failed    POST /harryzcy/instant-push/actions/runs/296/jobs/0 for 10.42.1.205:44104, panic in 162.9ms @ actions/view.go:95(actions.ViewPost), err=runtime error: index out of range [427] with length 427
2023/05/01 04:44:57 [644f43c9-8] router: completed POST /api/actions/runner.v1.RunnerService/UpdateLog for 10.42.1.205:44104, 200 OK in 84.6ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)
2023/05/01 04:44:58 [644f43c9-9] router: completed POST /api/actions/runner.v1.RunnerService/UpdateTask for 10.42.1.205:44104, 200 OK in 108.0ms @ <autogenerated>:1(http.Handler.ServeHTTP-fm)

Gitea Version

1.19.2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

Ubuntu 22.04

How are you running Gitea?

in Docker

Database

PostgreSQL

@silverwind silverwind added the topic/gitea-actions related to the actions of Gitea label May 1, 2023
@silverwind silverwind changed the title Panic while serving request Panic index out of range while serving request May 1, 2023
@silverwind silverwind changed the title Panic index out of range while serving request Panic index out of range in routers/web/repo/actions/view.go May 1, 2023
@silverwind
Copy link
Member

What page/URL were you one?

@wxiaoguang
Copy link
Contributor

That logic is quite complex, could you help to show the database record for that ActionTask?

It could be some possible problems (just a guess):

  1. Frontend bug, incorrect cursor
  2. Backend bug, cursor mapping problem
  3. Concurrency race bug, the LogIndexes is corrupted

@harryzcy
Copy link
Contributor Author

harryzcy commented May 1, 2023

That logic is quite complex, could you help to show the database record for that ActionTask?

Do you mean the actual data in action_task table?

image

@wxiaoguang
Copy link
Contributor

Yes, if it is reproducible. There is a mapping in LogIndexes for log lines, it panics there.

@wolfogre
Copy link
Member

wolfogre commented May 4, 2023

It's OK for frontend to request with a incorrect cursor.

if c := cursor.Cursor; c < step.LogLength && c >= 0 {

So it's a backend bug. I'm 90% sure what happened is:

  • Loaded task from database.
  • New logs had been uploaded, so the LogLength of the step was updated. The LogIndexes of the task were also updated, but not the data in memory.
  • Loaded steps from database.
  • Now there were new steps data and old task data in monery.

See

task, err = actions_model.GetTaskByID(ctx, current.TaskID)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}
task.Job = current
if err := task.LoadAttributes(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}

@wolfogre
Copy link
Member

wolfogre commented May 6, 2023

It may also be related to https://gitea.com/gitea/act_runner/pulls/176, and #24516 can prevent panic if it is true.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/gitea-actions related to the actions of Gitea type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants