PANIC: runtime error: invalid memory address or nil pointer dereference #14767

Closed
opened 2025-11-02 11:22:29 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @meth00dman1987 on GitHub (Jul 16, 2025).

Description

One of the repositories stopped opening. It is not known when exactly this happened. The last commit was on June 26, 2025. When trying to access the repository, an error occurred:

PANIC: runtime error: invalid memory address or nil pointer dereference
/snap/go/10907/src/runtime/panic.go:792 (0x47d911)
/build/gitea/parts/gitea/build/modules/web/routing/logger_manager.go:116 (0x180e764)
/snap/go/10907/src/runtime/panic.go:792 (0x47d911)
/snap/go/10907/src/runtime/panic.go:262 (0x47fff8)
/snap/go/10907/src/runtime/signal_unix.go:925 (0x47ffc8)
/build/gitea/parts/gitea/build/modules/git/commit_info.go:21 (0xe9daa3)
/build/gitea/parts/gitea/build/modules/git/commit_info_nogogit.go:70 (0xe9e0b2)
/build/gitea/parts/gitea/build/routers/web/repo/view.go:302 (0x2a2fea4)
/build/gitea/parts/gitea/build/routers/web/repo/view_home.go:136 (0x2a35aab)
/build/gitea/parts/gitea/build/routers/web/repo/view_home.go:340 (0x2a37f6d)
/build/gitea/parts/gitea/build/routers/web/repo/view_home.go:469 (0x2a37901)
/snap/go/10907/src/reflect/value.go:584 (0x50c405)
/snap/go/10907/src/reflect/value.go:368 (0x50b518)
/build/gitea/parts/gitea/build/modules/web/handler.go:161 (0x1818076)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/chain.go:31 (0x180f045)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/middleware/get_head.go:37 (0x297d20a)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/services/context/context.go:209 (0x1e127d8)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20240316035857-16768d98ec96/session.go:257 (0x17b7c0d)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:73 (0x180fc8e)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:325 (0x18115fa)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:73 (0x180fc8e)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:325 (0x18115fa)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/routing/logger_manager.go:122 (0x180e5ee)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x28c5fb3)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/routers/common/middleware.go:78 (0x28c829c)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/routers/common/middleware.go:93 (0x28c7e12)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535)
/snap/go/10907/src/net/http/server.go:2294 (0x91d788)
/root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:90 (0x180fc4d)
/build/gitea/parts/gitea/build/modules/web/router.go:243 (0x1819ffb)
/build/gitea/parts/gitea/build/modules/web/router.go:181 (0x1819a26)
/snap/go/10907/src/net/http/server.go:3301 (0x93e24d)
/snap/go/10907/src/net/http/server.go:2102 (0x91bc84)
/snap/go/10907/src/runtime/asm_amd64.s:1700 (0x485f80)

The rest of the repositories work correctly, only one is unavailable.

Found a similar problem https://github.com/go-gitea/gitea/issues/26331
The solution indicates that it has been fixed.

Gitea Version

1.24.3 built with GNU Make 4.3, go1.24.4: bindata, sqlite, sqlite_unlock_notify, pam, cert

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.25.1

Operating System

Ubuntu 20.04

How are you running Gitea?

Snap

Database

PostgreSQL

Originally created by @meth00dman1987 on GitHub (Jul 16, 2025). ### Description One of the repositories stopped opening. It is not known when exactly this happened. The last commit was on June 26, 2025. When trying to access the repository, an error occurred: PANIC: runtime error: invalid memory address or nil pointer dereference /snap/go/10907/src/runtime/panic.go:792 (0x47d911) /build/gitea/parts/gitea/build/modules/web/routing/logger_manager.go:116 (0x180e764) /snap/go/10907/src/runtime/panic.go:792 (0x47d911) /snap/go/10907/src/runtime/panic.go:262 (0x47fff8) /snap/go/10907/src/runtime/signal_unix.go:925 (0x47ffc8) /build/gitea/parts/gitea/build/modules/git/commit_info.go:21 (0xe9daa3) /build/gitea/parts/gitea/build/modules/git/commit_info_nogogit.go:70 (0xe9e0b2) /build/gitea/parts/gitea/build/routers/web/repo/view.go:302 (0x2a2fea4) /build/gitea/parts/gitea/build/routers/web/repo/view_home.go:136 (0x2a35aab) /build/gitea/parts/gitea/build/routers/web/repo/view_home.go:340 (0x2a37f6d) /build/gitea/parts/gitea/build/routers/web/repo/view_home.go:469 (0x2a37901) /snap/go/10907/src/reflect/value.go:584 (0x50c405) /snap/go/10907/src/reflect/value.go:368 (0x50b518) /build/gitea/parts/gitea/build/modules/web/handler.go:161 (0x1818076) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/chain.go:31 (0x180f045) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/middleware/get_head.go:37 (0x297d20a) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:168 (0x18180e5) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/services/context/context.go:209 (0x1e127d8) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/gitea.com/go-chi/session@v0.0.0-20240316035857-16768d98ec96/session.go:257 (0x17b7c0d) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:73 (0x180fc8e) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:325 (0x18115fa) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:73 (0x180fc8e) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:325 (0x18115fa) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:478 (0x18121e1) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/routing/logger_manager.go:122 (0x180e5ee) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/chi-middleware/proxy@v1.1.1/middleware.go:37 (0x28c5fb3) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/routers/common/middleware.go:78 (0x28c829c) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/routers/common/middleware.go:93 (0x28c7e12) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /build/gitea/parts/gitea/build/modules/web/handler.go:125 (0x1818535) /snap/go/10907/src/net/http/server.go:2294 (0x91d788) /root/go/pkg/mod/github.com/go-chi/chi/v5@v5.2.2/mux.go:90 (0x180fc4d) /build/gitea/parts/gitea/build/modules/web/router.go:243 (0x1819ffb) /build/gitea/parts/gitea/build/modules/web/router.go:181 (0x1819a26) /snap/go/10907/src/net/http/server.go:3301 (0x93e24d) /snap/go/10907/src/net/http/server.go:2102 (0x91bc84) /snap/go/10907/src/runtime/asm_amd64.s:1700 (0x485f80) The rest of the repositories work correctly, only one is unavailable. Found a similar problem https://github.com/go-gitea/gitea/issues/26331 The solution indicates that it has been fixed. ### Gitea Version 1.24.3 built with GNU Make 4.3, go1.24.4: bindata, sqlite, sqlite_unlock_notify, pam, cert ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.25.1 ### Operating System Ubuntu 20.04 ### How are you running Gitea? Snap ### Database PostgreSQL
GiteaMirror added the type/bug label 2025-11-02 11:22:29 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jul 16, 2025):

It seems that there is an invalid submodule in the repo.

And it is a bug on Gitea side, it shouldn't panic ...

-> Fix submodule nil check #35096

@wxiaoguang commented on GitHub (Jul 16, 2025): It seems that there is an invalid submodule in the repo. And it is a bug on Gitea side, it shouldn't panic ... -> Fix submodule nil check #35096
Author
Owner

@wxiaoguang commented on GitHub (Jul 16, 2025):

As a workaround, you can also downgrade to 1.24.2 temporarily

@wxiaoguang commented on GitHub (Jul 16, 2025): As a workaround, you can also downgrade to 1.24.2 temporarily
Author
Owner

@wxiaoguang commented on GitHub (Jul 16, 2025):

The fix for 1.24 is ready in nightly build:

@wxiaoguang commented on GitHub (Jul 16, 2025): The fix for 1.24 is ready in nightly build: * https://dl.gitea.com/gitea/1.24-nightly/ * https://hub.docker.com/r/gitea/gitea/tags?name=1.24-nightly
Author
Owner

@urz-hgw commented on GitHub (Jul 17, 2025):

Thanks for the fix @wxiaoguang, I just tested the nightly build but there is still some issues.

In my case a user has a repository with folders as submodules, but the source does not exist anymore (404).

Gitea v1.24.2 shows the full repository with all files/folders and submodule commit id.

Gitea v1.24.3 throws a 500 and does not show anything at all

Gitea v1.24-nightly throws a 500 but shows every folder/file until the submodule folder, the submodule commit id link is not shown and the rest of the output is broken.

The log says:

gitea-1    | 2025/07/17 14:31:10 .../access/repo_permission.go:262:GetUserRepoPermission.1() [T] Permission Loaded for user <User 2:user> in repo <Repository 1803:user/cptest>, permissions: <Permission AccessMode=owner, 8 Units, 0 UnitsMode(s): [
gitea-1    | 	units[0]: ID=12853 RepoID=1803 Type=<UnitType:1:repo.code> Config={}
gitea-1    | 	units[1]: ID=12854 RepoID=1803 Type=<UnitType:2:repo.issues> Config={"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true,"EnableDependencies":true}
gitea-1    | 	units[2]: ID=12855 RepoID=1803 Type=<UnitType:3:repo.pulls> Config={"IgnoreWhitespaceConflicts":false,"AllowMerge":true,"AllowRebase":true,"AllowRebaseMerge":true,"AllowSquash":true,"AllowFastForwardOnly":true,"AllowManualMerge":false,"AutodetectManualMerge":false,"AllowRebaseUpdate":true,"DefaultDeleteBranchAfterMerge":false,"DefaultMergeStyle":"merge","DefaultAllowMaintainerEdit":false}
gitea-1    | 	units[3]: ID=12856 RepoID=1803 Type=<UnitType:4:repo.releases> Config={}
gitea-1    | 	units[4]: ID=12857 RepoID=1803 Type=<UnitType:5:repo.wiki> Config={}
gitea-1    | 	units[5]: ID=12858 RepoID=1803 Type=<UnitType:8:repo.projects> Config={"ProjectsMode":"all"}
gitea-1    | 	units[6]: ID=12859 RepoID=1803 Type=<UnitType:9:repo.packages> Config={}
gitea-1    | 	units[7]: ID=12860 RepoID=1803 Type=<UnitType:10:repo.actions> Config={"DisabledWorkflows":null}
gitea-1    | 	anonymousAccessMode: map[]
gitea-1    | 	everyoneAccessMode: map[]
gitea-1    | 	]>
gitea-1    | 2025/07/17 14:31:10 .../context/context_response.go:69:(*Context).HTML() [D] Template: repo/home
gitea-1    | 2025/07/17 14:31:10 .../context/context_response.go:87:(*Context).HTML() [E] Render failed: failed to render template: repo/home, error: template error: builtin(bindata):repo/view_list:27:33 : executing "repo/view_list" at <$submoduleFile.RefID>: error calling RefID: runtime error: invalid memory address or nil pointer dereference
gitea-1    | ----------------------------------------------------------------------
gitea-1    | 						@ {{ShortSha $submoduleFile.RefID}}
gitea-1    | 						                           ^
gitea-1    | ----------------------------------------------------------------------
gitea-1    | 2025/07/17 14:31:10 .../context/context_response.go:69:(*Context).HTML() [D] Template: status/500

Best regards
Daniel

@urz-hgw commented on GitHub (Jul 17, 2025): Thanks for the fix @wxiaoguang, I just tested the nightly build but there is still some issues. In my case a user has a repository with folders as submodules, but the source does not exist anymore (404). Gitea v1.24.2 shows the full repository with all files/folders and submodule commit id. Gitea v1.24.3 throws a 500 and does not show anything at all Gitea v1.24-nightly throws a 500 but shows every folder/file until the submodule folder, the submodule commit id link is not shown and the rest of the output is broken. The log says: ``` gitea-1 | 2025/07/17 14:31:10 .../access/repo_permission.go:262:GetUserRepoPermission.1() [T] Permission Loaded for user <User 2:user> in repo <Repository 1803:user/cptest>, permissions: <Permission AccessMode=owner, 8 Units, 0 UnitsMode(s): [ gitea-1 | units[0]: ID=12853 RepoID=1803 Type=<UnitType:1:repo.code> Config={} gitea-1 | units[1]: ID=12854 RepoID=1803 Type=<UnitType:2:repo.issues> Config={"EnableTimetracker":true,"AllowOnlyContributorsToTrackTime":true,"EnableDependencies":true} gitea-1 | units[2]: ID=12855 RepoID=1803 Type=<UnitType:3:repo.pulls> Config={"IgnoreWhitespaceConflicts":false,"AllowMerge":true,"AllowRebase":true,"AllowRebaseMerge":true,"AllowSquash":true,"AllowFastForwardOnly":true,"AllowManualMerge":false,"AutodetectManualMerge":false,"AllowRebaseUpdate":true,"DefaultDeleteBranchAfterMerge":false,"DefaultMergeStyle":"merge","DefaultAllowMaintainerEdit":false} gitea-1 | units[3]: ID=12856 RepoID=1803 Type=<UnitType:4:repo.releases> Config={} gitea-1 | units[4]: ID=12857 RepoID=1803 Type=<UnitType:5:repo.wiki> Config={} gitea-1 | units[5]: ID=12858 RepoID=1803 Type=<UnitType:8:repo.projects> Config={"ProjectsMode":"all"} gitea-1 | units[6]: ID=12859 RepoID=1803 Type=<UnitType:9:repo.packages> Config={} gitea-1 | units[7]: ID=12860 RepoID=1803 Type=<UnitType:10:repo.actions> Config={"DisabledWorkflows":null} gitea-1 | anonymousAccessMode: map[] gitea-1 | everyoneAccessMode: map[] gitea-1 | ]> gitea-1 | 2025/07/17 14:31:10 .../context/context_response.go:69:(*Context).HTML() [D] Template: repo/home gitea-1 | 2025/07/17 14:31:10 .../context/context_response.go:87:(*Context).HTML() [E] Render failed: failed to render template: repo/home, error: template error: builtin(bindata):repo/view_list:27:33 : executing "repo/view_list" at <$submoduleFile.RefID>: error calling RefID: runtime error: invalid memory address or nil pointer dereference gitea-1 | ---------------------------------------------------------------------- gitea-1 | @ {{ShortSha $submoduleFile.RefID}} gitea-1 | ^ gitea-1 | ---------------------------------------------------------------------- gitea-1 | 2025/07/17 14:31:10 .../context/context_response.go:69:(*Context).HTML() [D] Template: status/500 ``` Best regards Daniel
Author
Owner

@wxiaoguang commented on GitHub (Jul 17, 2025):

Then we need another fix ..... let me see

@wxiaoguang commented on GitHub (Jul 17, 2025): Then we need another fix ..... let me see
Author
Owner

@wxiaoguang commented on GitHub (Jul 19, 2025):

1.24 nightly (will be 1.24.4 soon), it is a stable release, and contains the new fix:

@wxiaoguang commented on GitHub (Jul 19, 2025): 1.24 nightly (will be 1.24.4 soon), it is a stable release, and contains the new fix: * https://dl.gitea.com/gitea/1.24-nightly/ * https://hub.docker.com/r/gitea/gitea/tags?name=1.24-nightly
Author
Owner

@urz-hgw commented on GitHub (Jul 19, 2025):

@wxiaoguang thanks a lot, I just re-tested with the nightly build. The 500 error message is gone and the repository is shown like before, except that the commit ID is no longer a link - which is probably intended, since the target does not exist anymore.

@urz-hgw commented on GitHub (Jul 19, 2025): @wxiaoguang thanks a lot, I just re-tested with the nightly build. The 500 error message is gone and the repository is shown like before, except that the commit ID is no longer a link - which is probably intended, since the target does not exist anymore.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14767