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

[bug] uters/routes/base.go:153:1() [E] PANIC: runtime error: invalid memory address or nil pointer dereference #15558

Closed
2 tasks done
eveslage opened this issue Apr 20, 2021 · 10 comments · Fixed by #15561
Closed
2 tasks done
Labels
Milestone

Comments

@eveslage
Copy link

  • Gitea version (or commit ref): 1.14.1
  • Git version: 2.29.2
  • Operating system:
    debian buster
  • Database (use [x]):
    • MySQL
  • Can you reproduce the bug at https://try.gitea.io:
    • No
  • Log gist:
    2021/04/20 18:15:28 ...uters/routes/base.go:153:1() [E] PANIC: runtime error: invalid memory address or nil pointer dereference
    /usr/local/go/src/runtime/panic.go:212 (0x43de1a)
    /usr/local/go/src/runtime/signal_unix.go:734 (0x457b72)
    /source/models/user.go:1465 (0x1506c66)
    /source/routers/repo/commit.go:362 (0x2084bb5)
    /source/modules/web/route.go:53 (0x1f7de6b)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/mux.go:436 (0x1b3720a)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/web/route.go:92 (0x1f7e3d6)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/web/route.go:92 (0x1f7e3d6)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/web/route.go:92 (0x1f7e3d6)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/middleware/get_head.go:37 (0x21ad921)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/context/context.go:704 (0x1b563a1)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/base.go:94 (0x21b4d21)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/base.go:94 (0x21b4d21)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/public/public.go:86 (0x13f4947)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/modules/public/public.go:86 (0x13f4947)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/base.go:199 (0x21b6910)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/gitea.com/go-chi/session/session.go:256 (0x154682e)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/mux.go:70 (0x1b34d6a)
    /source/vendor/github.com/go-chi/chi/mux.go:311 (0x1b3b15b)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/mux.go:436 (0x1b3720a)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/web.go:110 (0x21b7d5d)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/base.go:38 (0x21b399b)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/middleware/strip.go:30 (0x21ae227)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/chi-middleware/proxy/middleware.go:37 (0x21a988e)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/routers/routes/web.go:66 (0x21b789c)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /source/vendor/github.com/go-chi/chi/mux.go:87 (0x1b34af0)
    /source/modules/web/route.go:268 (0x1f7d3b3)
    /source/vendor/github.com/gorilla/context/context.go:141 (0x11b4b53)
    /usr/local/go/src/net/http/server.go:2069 (0x7bd0c3)
    /usr/local/go/src/net/http/server.go:2887 (0x7c0682)
    /usr/local/go/src/net/http/server.go:1952 (0x7bbbac)
    /usr/local/go/src/runtime/asm_amd64.s:1371 (0x47a4e0)

Description

getting a 500 error when opening a commit of a fairly large repo

git gc, git fsck all done, no issues detected

@zeripath
Copy link
Contributor

zeripath commented Apr 20, 2021

The panic is coming from:

if c.Author == nil {

Implying that the c passed in is nil

That comes from L362:

note := &git.Note{}
err = git.GetNote(ctx.Repo.GitRepo, commitID, note)
if err == nil {
ctx.Data["Note"] = string(charset.ToUTF8WithFallback(note.Message))
ctx.Data["NoteCommit"] = note.Commit
ctx.Data["NoteAuthor"] = models.ValidateCommitWithEmail(note.Commit)
}

Which implies that the problem is in git.GetNote(...)

Are you using the go-git variant or plain git variant?

@eveslage
Copy link
Author

tbh, I am not sure. I installed gitea as binary from the official repository. How would I notice the difference?

@zeripath
Copy link
Contributor

No problem so this is a bug in the native git backend then.

Would it be possible to try the following patch?

From 88f39bfc3f9e139450cbfc1b88f054efe5c26362 Mon Sep 17 00:00:00 2001
From: Andrew Thornton <art27@cantab.net>
Date: Tue, 20 Apr 2021 21:12:30 +0100
Subject: [PATCH] Fix NPE on view commit with notes

Fix #15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
---
 modules/git/notes_nogogit.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go
index 613efd2e0..1379e5085 100644
--- a/modules/git/notes_nogogit.go
+++ b/modules/git/notes_nogogit.go
@@ -8,6 +8,7 @@ package git
 
 import (
 	"io/ioutil"
+	"strings"
 )
 
 // GetNote retrieves the git-notes data for a given commit.
@@ -49,7 +50,13 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
 	}
 	note.Message = d
 
-	lastCommits, err := GetLastCommitForPaths(notes, "", []string{path})
+	treePath := ""
+	if idx := strings.LastIndex(path, "/"); idx > -1 {
+		treePath = path[:idx]
+		path = path[idx+1:]
+	}
+
+	lastCommits, err := GetLastCommitForPaths(notes, treePath, []string{path})
 	if err != nil {
 		return err
 	}
-- 
2.25.1

@eveslage
Copy link
Author

Do I have to build gitea for source to try out the patch?

@zeripath
Copy link
Contributor

yes - but I can build a v1.14.x version for you if you tell me which architecture you need

@eveslage
Copy link
Author

That would be nice. It's Debian buster x64

@zeripath
Copy link
Contributor

temporary build is up at https://eldritchkitty.com/~andrew/gitea-v1.14.x-15558-linux-amd64.gz

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE0s922pXyAemQFTKrPN50Yx8Tp0gFAmB/OgYACgkQPN50Yx8T
p0hKVA/6Ak5fcH3Myfzgn/JIOA792L1+w3apP6/3pxqq5CV63aDNvBjLnzEDqPWc
di8dfRNNut7MY/gSdbSl+wMROx5+D7inp1W0QaQCk7fg5ZbUna4inzpEkV5isfwv
1ZbOpaW+ElSP3AFkfLrYp9HmQ7a5WI28wHamUsxDLFYUdkoo9JC/453avP5g1k4/
88w5UFH/XSx2EPzlB98/Pnjogc48e9PW9kj1xDUTWsvZZnPhcAv1K534lCf2NmEr
eKPbjhCqA72XU4VehyUNDGleVPRItt9r6iKn6oUxws9ZWz7H7rTsCyv4AeL8hoEn
wXT/hVeN8Lzd6M4xPnd2DQkLHUnRl4NU42LBh2Wm+UDSQtFqEEIPT47tSdeKNWSv
2BKEWKbO/Q32ZBAYQWDzXLqtstlfsQW8z7UMfnH/HJhIRKS8kv95F8w8zwxRfz1V
UO2hzy33Ej1U0B6Itj9z4mSr0/4oPop/ttPn46FkdmciI/GHks8M5UqBG2rmlp9K
4xRJC6pVJoz4ETWvx7DhJycBdDHaReUu5h1Xpx2sKu4qSXvLsLc85TUjFri0QKd2
wEIEnAoOaH61kjz/zBVSme4Io/IZjLg/ULTzlp+ITjFQNcXD/RnsiWjzTFBA5rW2
K+kNWmko7BVKGmEwTiBq8ImlWjSkTD687HNMg13ve55k2OPYE1E=
=PNrd
-----END PGP SIGNATURE-----

is a signature for the gz file.

gunzip it once you've got it.

@eveslage
Copy link
Author

I will try the build tomorrow and keep you updated. Thanks

zeripath added a commit to zeripath/gitea that referenced this issue Apr 20, 2021
Fix go-gitea#15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
@lunny lunny added the type/bug label Apr 21, 2021
@lunny lunny added this to the 1.14.2 milestone Apr 21, 2021
@eveslage
Copy link
Author

fix confirmed, thanks for the quick help

@6543 6543 reopened this Apr 21, 2021
@6543
Copy link
Member

6543 commented Apr 21, 2021

keep it open until it got merged :)

zeripath added a commit that referenced this issue Apr 21, 2021
Fix #15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added a commit to zeripath/gitea that referenced this issue Apr 21, 2021
Backport go-gitea#15561

Fix go-gitea#15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
techknowlogick pushed a commit that referenced this issue Apr 21, 2021
Backport #15561

Fix #15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Jun 4, 2021
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
Fix go-gitea#15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants