If not sign in compare will return error 500 #5404

Closed
opened 2025-11-02 06:23:56 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @L0veSunshine on GitHub (May 15, 2020).

Description

When you don't sign in and click the compare button on repo's homepage, it will occur error 500

Screenshots

Originally created by @L0veSunshine on GitHub (May 15, 2020). - Gitea version (or commit ref): 1.12.0+dev-321-g57217cabe - Git version: - Operating system: - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide example URL) https://try.gitea.io/dcsdvcsd/asxasxsax/compare/master...master - [ ] No - [ ] Not relevant - Log gist: ## Description When you don't sign in and click the compare button on repo's homepage, it will occur error 500 ## Screenshots
Author
Owner

@zeripath commented on GitHub (May 15, 2020):

Logs would have been helpful.

@zeripath commented on GitHub (May 15, 2020): Logs would have been helpful.
Author
Owner

@L0veSunshine commented on GitHub (May 15, 2020):

Logs would have been helpful.

please wait a minute and i have locate the question.
maybe is here
57217cabe3/routers/repo/compare.go (L218)

@L0veSunshine commented on GitHub (May 15, 2020): > Logs would have been helpful. please wait a minute and i have locate the question. maybe is here https://github.com/go-gitea/gitea/blob/57217cabe34e2a01fbb3cb93bd93fbefa38fee91/routers/repo/compare.go#L218
Author
Owner

@L0veSunshine commented on GitHub (May 15, 2020):

Here is the log

2020/05/14 12:57:18 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
/home/go/src/runtime/panic.go:212 (0x456c19)
panicmem: panic(memoryError)
/home/go/src/runtime/signal_unix.go:687 (0x456a68)
sigpanic: panicmem()
/home/gitea-sync/routers/repo/compare.go:218 (0x1991419)
ParseCompareInfo: if ctx.User.ID != 0 {
/home/gitea-sync/routers/repo/compare.go:521 (0x1994e7f)
CompareDiff: headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx)
/home/go/src/reflect/value.go:460 (0x4a070a)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/home/go/src/reflect/value.go:321 (0x49fc13)
Value.Call: return v.call("Call", in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b)
(*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359)
(*injector).Invoke: return inj.callInvoke(f, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x116e06f)
(*Context).Next: c.run()
/home/gitea-sync/modules/context/repo.go:579 (0x116e058)
RepoAssignment.func1: ctx.Next()
/home/go/src/reflect/value.go:460 (0x4a070a)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/home/go/src/reflect/value.go:321 (0x49fc13)
Value.Call: return v.call("Call", in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b)
(*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359)
(*injector).Invoke: return inj.callInvoke(f, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x116b964)
(*Context).Next: c.run()
/home/gitea-sync/modules/context/panic.go:39 (0x116b955)
Recovery.func1: ctx.Next()
/home/go/src/reflect/value.go:460 (0x4a070a)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/home/go/src/reflect/value.go:321 (0x49fc13)
Value.Call: return v.call("Call", in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b)
(*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359)
(*injector).Invoke: return inj.callInvoke(f, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x1123935)
(*Context).Next: c.run()
/home/gitea-sync/vendor/gitea.com/macaron/session/session.go:192 (0x1123920)
Sessioner.func1: ctx.Next()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:79 (0xc36750)
ContextInvoker.Invoke: invoke(params[0].(*Context))
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7)
(*injector).fastInvoke: return f.Invoke(in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448)
(*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0xc47cd5)
(*Context).Next: c.run()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/recovery.go:161 (0xc47cc8)
Recovery.func1: c.Next()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc3a313)
LoggerInvoker.Invoke: invoke(params[0].(*Context), params[1].(*log.Logger))
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7)
(*injector).fastInvoke: return f.Invoke(in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448)
(*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0xc47000)
(*Context).Next: c.run()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:52 (0xc46feb)
Logger.func1: ctx.Next()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc3a313)
LoggerInvoker.Invoke: invoke(params[0].(*Context), params[1].(*log.Logger))
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7)
(*injector).fastInvoke: return f.Invoke(in)
/home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448)
(*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/gitea-sync/vendor/gitea.com/macaron/macaron/router.go:187 (0xc48ee6)
(*Router).Handle.func1: c.run()
/home/gitea-sync/vendor/gitea.com/macaron/macaron/router.go:303 (0xc428e5)
(*Router).ServeHTTP: h(rw, req, p)
/home/gitea-sync/vendor/gitea.com/macaron/macaron/macaron.go:218 (0xc3b66a)
(*Macaron).ServeHTTP: m.Router.ServeHTTP(rw, req)
/home/gitea-sync/vendor/github.com/gorilla/context/context.go:141 (0xead023)
ClearHandler.func1: h.ServeHTTP(w, r)
/home/go/src/net/http/server.go:2012 (0x7582c3)
HandlerFunc.ServeHTTP: f(w, r)
/home/go/src/net/http/server.go:2807 (0x75b652)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/home/go/src/net/http/server.go:1895 (0x7570cb)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/home/go/src/runtime/asm_amd64.s:1373 (0x472c10)
goexit: BYTE $0x90 // NOP

@L0veSunshine commented on GitHub (May 15, 2020): # Here is the log 2020/05/14 12:57:18 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference /home/go/src/runtime/panic.go:212 (0x456c19) panicmem: panic(memoryError) /home/go/src/runtime/signal_unix.go:687 (0x456a68) sigpanic: panicmem() /home/gitea-sync/routers/repo/compare.go:218 (0x1991419) ParseCompareInfo: if ctx.User.ID != 0 { /home/gitea-sync/routers/repo/compare.go:521 (0x1994e7f) CompareDiff: headUser, headRepo, headGitRepo, compareInfo, baseBranch, headBranch := ParseCompareInfo(ctx) /home/go/src/reflect/value.go:460 (0x4a070a) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /home/go/src/reflect/value.go:321 (0x49fc13) Value.Call: return v.call("Call", in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b) (*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359) (*injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x116e06f) (*Context).Next: c.run() /home/gitea-sync/modules/context/repo.go:579 (0x116e058) RepoAssignment.func1: ctx.Next() /home/go/src/reflect/value.go:460 (0x4a070a) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /home/go/src/reflect/value.go:321 (0x49fc13) Value.Call: return v.call("Call", in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b) (*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359) (*injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x116b964) (*Context).Next: c.run() /home/gitea-sync/modules/context/panic.go:39 (0x116b955) Recovery.func1: ctx.Next() /home/go/src/reflect/value.go:460 (0x4a070a) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /home/go/src/reflect/value.go:321 (0x49fc13) Value.Call: return v.call("Call", in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:177 (0xc1b97b) (*injector).callInvoke: return reflect.ValueOf(f).Call(in), nil /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:137 (0xc1b359) (*injector).Invoke: return inj.callInvoke(f, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0x1123935) (*Context).Next: c.run() /home/gitea-sync/vendor/gitea.com/macaron/session/session.go:192 (0x1123920) Sessioner.func1: ctx.Next() /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:79 (0xc36750) ContextInvoker.Invoke: invoke(params[0].(*Context)) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7) (*injector).fastInvoke: return f.Invoke(in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448) (*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0xc47cd5) (*Context).Next: c.run() /home/gitea-sync/vendor/gitea.com/macaron/macaron/recovery.go:161 (0xc47cc8) Recovery.func1: c.Next() /home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc3a313) LoggerInvoker.Invoke: invoke(params[0].(*Context), params[1].(*log.Logger)) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7) (*injector).fastInvoke: return f.Invoke(in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448) (*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:112 (0xc47000) (*Context).Next: c.run() /home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:52 (0xc46feb) Logger.func1: ctx.Next() /home/gitea-sync/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc3a313) LoggerInvoker.Invoke: invoke(params[0].(*Context), params[1].(*log.Logger)) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:157 (0xc1b6a7) (*injector).fastInvoke: return f.Invoke(in) /home/gitea-sync/vendor/gitea.com/macaron/inject/inject.go:135 (0xc1b448) (*injector).Invoke: return inj.fastInvoke(v, t, t.NumIn()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/context.go:121 (0xc368a8) (*Context).run: vals, err := c.Invoke(c.handler()) /home/gitea-sync/vendor/gitea.com/macaron/macaron/router.go:187 (0xc48ee6) (*Router).Handle.func1: c.run() /home/gitea-sync/vendor/gitea.com/macaron/macaron/router.go:303 (0xc428e5) (*Router).ServeHTTP: h(rw, req, p) /home/gitea-sync/vendor/gitea.com/macaron/macaron/macaron.go:218 (0xc3b66a) (*Macaron).ServeHTTP: m.Router.ServeHTTP(rw, req) /home/gitea-sync/vendor/github.com/gorilla/context/context.go:141 (0xead023) ClearHandler.func1: h.ServeHTTP(w, r) /home/go/src/net/http/server.go:2012 (0x7582c3) HandlerFunc.ServeHTTP: f(w, r) /home/go/src/net/http/server.go:2807 (0x75b652) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /home/go/src/net/http/server.go:1895 (0x7570cb) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /home/go/src/runtime/asm_amd64.s:1373 (0x472c10) goexit: BYTE $0x90 // NOP
Author
Owner

@zeripath commented on GitHub (May 15, 2020):

Thanks I've already put up a fix - it was actually very simple to reproduce.

I unfortunately caused it.

@zeripath commented on GitHub (May 15, 2020): Thanks I've already put up a fix - it was actually very simple to reproduce. I unfortunately caused it.
Author
Owner

@L0veSunshine commented on GitHub (May 15, 2020):

Thanks I've already put up a fix - it was actually very simple to reproduce.

I unfortunately caused it.

The code in compare.go is really awful before your commit.
By the way, your annotate is clearly and useful.
Thanks for your pr.

@L0veSunshine commented on GitHub (May 15, 2020): > Thanks I've already put up a fix - it was actually very simple to reproduce. > > I unfortunately caused it. The code in compare.go is really awful before [your commit.](https://github.com/go-gitea/gitea/pull/11327) By the way, your annotate is clearly and useful. Thanks for your pr.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5404