Gitea: Panic in git blame

Created on 6 Aug 2020  路  12Comments  路  Source: go-gitea/gitea

  • Gitea version (or commit ref): 1.12.3
  • Git version: 2.17.1
  • Operating system: Ubuntu Server 18.04
  • Database (use [x]):

    • [ ] PostgreSQL

    • [ ] MySQL

    • [ ] MSSQL

    • [x] SQLite

  • Can you reproduce the bug at https://try.gitea.io:

    • [ ] Yes (provide example URL)

    • [ ] No

    • [x] Not relevant

  • Log gist:

Description

When accessing a specific git blame, I get a HTTP error 500. I noticed this because the Googlebot was indexing my git server, and caught it. The specific URL is as follows: https://git.starbeamrainbowlabs.com/sbrl-github/Pepperminty-Wiki/blame/commit/edba3b9bf3af109935a8ec7dc76914611b0dcb2f/php_error.php

This particular repo is a backup mirror of https://github.com/sbrl/Pepperminty-Wiki, so the specific URL on GitHub is as follows: https://github.com/sbrl/Pepperminty-Wiki/blame/edba3b9bf3af109935a8ec7dc76914611b0dcb2f/php_error.php

Just thought I'd report, since it seems like a crash that might need fixing. Feel free to close this if it can't be debugged :-)

Screenshots


image

Stack trace from logs:

2020/08/06 02:04:32 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
    /usr/local/go/src/runtime/panic.go:212 (0x452e59)
    /usr/local/go/src/runtime/signal_unix.go:695 (0x452ca8)
    /go/src/code.gitea.io/gitea/modules/git/blame.go:70 (0x9f9e74)
    /go/src/code.gitea.io/gitea/routers/repo/blame.go:160 (0x19a223b)
    /usr/local/go/src/reflect/value.go:460 (0x49cc3a)
    /usr/local/go/src/reflect/value.go:321 (0x49c143)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc2861b)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc27ff9)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x125dd74)
    /go/src/code.gitea.io/gitea/modules/context/repo.go:797 (0x125dd5d)
    /usr/local/go/src/reflect/value.go:460 (0x49cc3a)
    /usr/local/go/src/reflect/value.go:321 (0x49c143)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc2861b)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc27ff9)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x125c45f)
    /go/src/code.gitea.io/gitea/modules/context/repo.go:579 (0x125c448)
    /usr/local/go/src/reflect/value.go:460 (0x49cc3a)
    /usr/local/go/src/reflect/value.go:321 (0x49c143)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc2861b)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc27ff9)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x1259d54)
    /go/src/code.gitea.io/gitea/modules/context/panic.go:39 (0x1259d45)
    /usr/local/go/src/reflect/value.go:460 (0x49cc3a)
    /usr/local/go/src/reflect/value.go:321 (0x49c143)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:177 (0xc2861b)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:137 (0xc27ff9)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x1211935)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/session/session.go:192 (0x1211920)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:79 (0xc433f0)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0xc28347)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0xc280e8)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0x1b497c7)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/gzip/gzip.go:139 (0x1b497ba)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:79 (0xc433f0)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0xc28347)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0xc280e8)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xc54975)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/recovery.go:161 (0xc54968)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc46fb3)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0xc28347)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0xc280e8)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:112 (0xc53ca0)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:52 (0xc53c8b)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/logger.go:40 (0xc46fb3)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:157 (0xc28347)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/inject/inject.go:135 (0xc280e8)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/context.go:121 (0xc43548)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/router.go:187 (0xc55b86)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/router.go:303 (0xc4f585)
    /go/src/code.gitea.io/gitea/vendor/gitea.com/macaron/macaron/macaron.go:218 (0xc4830a)
    /go/src/code.gitea.io/gitea/vendor/github.com/gorilla/context/context.go:141 (0xeba293)
    /usr/local/go/src/net/http/server.go:2041 (0x750943)
    /usr/local/go/src/net/http/server.go:2836 (0x753cd2)
    /usr/local/go/src/net/http/server.go:1924 (0x74f73b)
    /usr/local/go/src/runtime/asm_amd64.s:1373 (0x46f030)

kinbug revieweconfirmed

Most helpful comment

Is it fixed or not? It is the last ticket in milestone 1.13

All 12 comments

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

Did some debugging on this.
The issue is the scanner exits early on"bufio.Scanner: token too long".

https://golang.org/pkg/bufio/#Scanner

Scanning stops unrecoverably at EOF, the first I/O error, or a token too large to fit in the buffer. When a scan stops, the reader may have advanced arbitrarily far past the last token. Programs that need more control over error handling or large tokens, or must run sequential scans on a reader, should use bufio.Reader instead.

I'm seeing a lot of zombie git blame processes in my Gitea docker container, that I think are related to this issue:

https://gist.github.com/mappu/158ba6089f7f895554e4e9ec2be075f8 Output of ps fuxa

These files are all go-bindata -type files with very long lines. It seems like no Gitea process is reading their stdin any more so the process is never properly closed.

What version of Gitea are you using?

Sorry, that was from a 1.11.4 server, and I can see it was already fixed in #11716 for 1.12. :+1:

Is it fixed or not? It is the last ticket in milestone 1.13

This is not fixed yet

Thanks, everyone for fixing this :D

the fix in #13470 is not a complete fix - it could do with a little more finesse as I wrote on the PR itself.

(not least because the 4096 byte stripper could end up splitting within a rune.)

Was this page helpful?
0 / 5 - 0 ratings