compare: index out of range panic on master and v1.11 #4662

Closed
opened 2025-11-02 05:58:33 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @silverwind on GitHub (Jan 16, 2020).

  • Gitea version (or commit ref): cc2916dc5a
  • Git version: 2.22.0
  • Operating system: Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant

Description

Panic when opening a page compare/master...branch. Stack looks similar to https://github.com/go-gitea/gitea/issues/9173 and https://github.com/go-gitea/gitea/issues/9217 but https://github.com/go-gitea/gitea/pull/9187 did not fix it. I can reproduce on both master and v1.11 release branch. I can't share the diff, but may be able to answer questions about it.

2020/01/17 02:12:33 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: index out of range [-1]
  /usr/lib/golang/src/runtime/panic.go:75 (0x42f8b2)
    goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
  gitea/services/gitdiff/gitdiff.go:358 (0x12fdf83)
  gitea/services/gitdiff/gitdiff.go:870 (0x1301c74)
  gitea/services/gitdiff/gitdiff.go:811 (0x1404a2f)
  gitea/routers/repo/compare.go:282 (0x1404984)
  gitea/routers/repo/compare.go:387 (0x1405f33)
  /usr/lib/golang/src/reflect/value.go:460 (0x491b15)
    Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
  /usr/lib/golang/src/reflect/value.go:321 (0x4912d3)
    Value.Call: return v.call("Call", in)
  gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9)
  gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xfc8f01)
  gitea/modules/context/repo.go:576 (0xfc8eea)
  /usr/lib/golang/src/reflect/value.go:460 (0x491b15)
    Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
  /usr/lib/golang/src/reflect/value.go:321 (0x4912d3)
    Value.Call: return v.call("Call", in)
  gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9)
  gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xfc68f1)
  gitea/modules/context/panic.go:39 (0xfc68dd)
  /usr/lib/golang/src/reflect/value.go:460 (0x491b15)
    Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
  /usr/lib/golang/src/reflect/value.go:321 (0x4912d3)
    Value.Call: return v.call("Call", in)
  gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9)
  gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xa79cd5)
#!/bin/bash
  gitea/vendor/gitea.com/macaron/session/session.go:192 (0xa79cc0)
  gitea/vendor/gitea.com/macaron/macaron/context.go:79 (0x9e1920)
  gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09)
  gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9f3059)
  gitea/vendor/gitea.com/macaron/macaron/recovery.go:161 (0x9f3047)
  gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e55f3)
  gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09)
  gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9f2390)
  gitea/vendor/gitea.com/macaron/macaron/logger.go:52 (0x9f237b)
  gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e55f3)
  gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09)
  gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998)
  gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78)
  gitea/vendor/gitea.com/macaron/macaron/router.go:187 (0x9f4276)
  gitea/vendor/gitea.com/macaron/macaron/router.go:303 (0x9edc55)
  gitea/vendor/gitea.com/macaron/macaron/macaron.go:218 (0x9e698a)
  gitea/vendor/github.com/gorilla/context/context.go:141 (0xd1846d)
  /usr/lib/golang/src/net/http/server.go:2007 (0x751bc3)
    HandlerFunc.ServeHTTP: f(w, r)
  /usr/lib/golang/src/net/http/server.go:2802 (0x755013)
    serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
  /usr/lib/golang/src/net/http/server.go:1890 (0x7509b4)
    (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
  /usr/lib/golang/src/runtime/asm_amd64.s:1357 (0x461150)
    goexit: BYTE  $0x90 // NOP
Originally created by @silverwind on GitHub (Jan 16, 2020). - Gitea version (or commit ref): https://github.com/go-gitea/gitea/commit/cc2916dc5acea2c32372082986f8c2e2c43e55fe - Git version: 2.22.0 - Operating system: Linux - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant ## Description Panic when opening a page `compare/master...branch`. Stack looks similar to https://github.com/go-gitea/gitea/issues/9173 and https://github.com/go-gitea/gitea/issues/9217 but https://github.com/go-gitea/gitea/pull/9187 did not fix it. I can reproduce on both master and v1.11 release branch. I can't share the diff, but may be able to answer questions about it. ```` 2020/01/17 02:12:33 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: index out of range [-1] /usr/lib/golang/src/runtime/panic.go:75 (0x42f8b2) goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex}) gitea/services/gitdiff/gitdiff.go:358 (0x12fdf83) gitea/services/gitdiff/gitdiff.go:870 (0x1301c74) gitea/services/gitdiff/gitdiff.go:811 (0x1404a2f) gitea/routers/repo/compare.go:282 (0x1404984) gitea/routers/repo/compare.go:387 (0x1405f33) /usr/lib/golang/src/reflect/value.go:460 (0x491b15) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /usr/lib/golang/src/reflect/value.go:321 (0x4912d3) Value.Call: return v.call("Call", in) gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9) gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xfc8f01) gitea/modules/context/repo.go:576 (0xfc8eea) /usr/lib/golang/src/reflect/value.go:460 (0x491b15) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /usr/lib/golang/src/reflect/value.go:321 (0x4912d3) Value.Call: return v.call("Call", in) gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9) gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xfc68f1) gitea/modules/context/panic.go:39 (0xfc68dd) /usr/lib/golang/src/reflect/value.go:460 (0x491b15) Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset)) /usr/lib/golang/src/reflect/value.go:321 (0x4912d3) Value.Call: return v.call("Call", in) gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0x9b0ef9) gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0x9b08a9) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xa79cd5) #!/bin/bash gitea/vendor/gitea.com/macaron/session/session.go:192 (0xa79cc0) gitea/vendor/gitea.com/macaron/macaron/context.go:79 (0x9e1920) gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09) gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9f3059) gitea/vendor/gitea.com/macaron/macaron/recovery.go:161 (0x9f3047) gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e55f3) gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09) gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x9f2390) gitea/vendor/gitea.com/macaron/macaron/logger.go:52 (0x9f237b) gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0x9e55f3) gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0x9b0c09) gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0x9b0998) gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0x9e1a78) gitea/vendor/gitea.com/macaron/macaron/router.go:187 (0x9f4276) gitea/vendor/gitea.com/macaron/macaron/router.go:303 (0x9edc55) gitea/vendor/gitea.com/macaron/macaron/macaron.go:218 (0x9e698a) gitea/vendor/github.com/gorilla/context/context.go:141 (0xd1846d) /usr/lib/golang/src/net/http/server.go:2007 (0x751bc3) HandlerFunc.ServeHTTP: f(w, r) /usr/lib/golang/src/net/http/server.go:2802 (0x755013) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /usr/lib/golang/src/net/http/server.go:1890 (0x7509b4) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /usr/lib/golang/src/runtime/asm_amd64.s:1357 (0x461150) goexit: BYTE $0x90 // NOP ````
GiteaMirror added the type/bug label 2025-11-02 05:58:33 -06:00
Author
Owner

@lafriks commented on GitHub (Jan 16, 2020):

Could it be that #9808 fixed this?

@lafriks commented on GitHub (Jan 16, 2020): Could it be that #9808 fixed this?
Author
Owner

@silverwind commented on GitHub (Jan 16, 2020):

@lunny is it related?

@silverwind commented on GitHub (Jan 16, 2020): @lunny is it related?
Author
Owner

@lunny commented on GitHub (Jan 17, 2020):

@silverwind Maybe. I just review the code and found that. Since #9808 merged, could you confirm that? I will send back port to v1.11 and v1.10

@lunny commented on GitHub (Jan 17, 2020): @silverwind Maybe. I just review the code and found that. Since #9808 merged, could you confirm that? I will send back port to v1.11 and v1.10
Author
Owner

@silverwind commented on GitHub (Jan 17, 2020):

Unfortunately, no, it does not fix it. Updated stacktrace which is now for cc2916dc5a.

@silverwind commented on GitHub (Jan 17, 2020): Unfortunately, no, it does not fix it. Updated stacktrace which is now for https://github.com/go-gitea/gitea/commit/cc2916dc5acea2c32372082986f8c2e2c43e55fe.
Author
Owner

@lunny commented on GitHub (Jan 17, 2020):

So there is a file has changes but there is no any section. @silverwind Could you paste that patch?

@lunny commented on GitHub (Jan 17, 2020): So there is a file has changes but there is no any section. @silverwind Could you paste that patch?
Author
Owner

@silverwind commented on GitHub (Jan 17, 2020):

Afraid I can not share the private patch data, I'll check it out myself later.

@silverwind commented on GitHub (Jan 17, 2020): Afraid I can not share the private patch data, I'll check it out myself later.
Author
Owner

@silverwind commented on GitHub (Jan 21, 2020):

@lunny It can be reproduced with a simple file mode change:

https://try.gitea.io/silverwind/symlink-test/compare/master...mode

$ git diff master mode
diff --git a/file b/file
old mode 100644
new mode 100755
@silverwind commented on GitHub (Jan 21, 2020): @lunny It can be reproduced with a simple file mode change: https://try.gitea.io/silverwind/symlink-test/compare/master...mode ```` diff $ git diff master mode diff --git a/file b/file old mode 100644 new mode 100755
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4662