Skip to content

[SubModule Nil Pointer] Missing .gitmodules with submodule symlink repos cause PANIC #35115

@Treenity

Description

@Treenity

Description

Hi there,

Context

Just to give some context, we use gitea + jenkins, when we push our micro-services a Jenkins pipeline build our microservice OpenApi clients, each client have his own repository, so when we build our microservice, jenkins get the client repository, build the new one on it, then git add . / git commit it.

Our CI, before pushing new client, can make some test (for our Java client) using centralised configuration from another repository, the CI checkout the current client project, apply new files on it, git clone the gradle-config from another repo, add all and commit.

Problem

it create a symlink(submodule) directory which is commited, but not added to .gitmodules, this cause PANIF crash in gitea web interface because of modules/git/commit_info.go l.21

gitea have identified the directory as a submodule, and try to checkout this submodule, but because of the missing .gitmodule file it can't get enough informations, resulting(i think) in a null pointer to the NewCommitSubmoduleFile method, causing the crash.

I think we didn't had the problem in the previous version maybe because they were a silent error, or submodule was just skipped because of the lack of .gitmodule, not sure of that, but it was working before.

I Agree that the problem come from a user error, making git clone of other project, inside a comited project, but it should not create 500 error in the web interface.

here is the full stacktrace:

PANIC: runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:792 (0x47da31)
/go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:116 (0x180eaa4)
/usr/local/go/src/runtime/panic.go:792 (0x47da31)
/usr/local/go/src/runtime/panic.go:262 (0x480118)
/usr/local/go/src/runtime/signal_unix.go:925 (0x4800e8)
/go/src/code.gitea.io/gitea/modules/git/commit_info.go:21 (0xe9ddc3)
/go/src/code.gitea.io/gitea/modules/git/commit_info_nogogit.go:70 (0xe9e3d2)
/go/src/code.gitea.io/gitea/routers/web/repo/view.go:302 (0x2a2d5e4)
/go/src/code.gitea.io/gitea/routers/web/repo/view_home.go:136 (0x2a331eb)
/go/src/code.gitea.io/gitea/routers/web/repo/view_home.go:340 (0x2a356ad)
/go/src/code.gitea.io/gitea/routers/web/repo/view_home.go:469 (0x2a35041)
/usr/local/go/src/reflect/value.go:584 (0x50cc45)
/usr/local/go/src/reflect/value.go:368 (0x50bd58)
/go/src/code.gitea.io/gitea/modules/web/handler.go:161 (0x18183b6)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/chain.go:31 (0x180f385)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:478 (0x1812521)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/get_head.go:37 (0x297a94a)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:168 (0x1818425)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/services/context/context.go:209 (0x1e12b38)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/gitea.com/go-chi/[email protected]/session.go:257 (0x17b7f4d)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73 (0x180ffce)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:325 (0x181193a)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:478 (0x1812521)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:73 (0x180ffce)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:325 (0x181193a)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:478 (0x1812521)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/routing/logger_manager.go:122 (0x180e92e)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/chi-middleware/[email protected]/middleware.go:37 (0x28c36f3)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/routers/common/middleware.go:78 (0x28c59dc)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/routers/common/middleware.go:93 (0x28c5552)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/src/code.gitea.io/gitea/modules/web/handler.go:125 (0x1818875)
/usr/local/go/src/net/http/server.go:2294 (0x91dd48)
/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:90 (0x180ff8d)
/go/src/code.gitea.io/gitea/modules/web/router.go:243 (0x181a33b)
/go/src/code.gitea.io/gitea/modules/web/router.go:181 (0x1819d66)
/usr/local/go/src/net/http/server.go:3301 (0x93e80d)
/usr/local/go/src/net/http/server.go:2102 (0x91c244)
/usr/local/go/src/runtime/asm_amd64.s:1700 (0x4860a0)

Gitea Version

1.24.3

Can you reproduce the bug on the Gitea demo site?

Yes, i could of i didnt had a 500 error when registered ;)
Simply create a repo, pull it, make some git clone inside(without adding them with git module) and commit/push all, it will return a 500 error when you try to reach the project homepage

Log Gist

No response

Screenshots

No response

Git Version

2.49.1

Operating System

Alpine Linux v3.22

How are you running Gitea?

Gitea is running with gitea/gitea:1.24.3 docker image

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions