Skip to content

Panic in git blame #12440

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

Closed
2 of 7 tasks
sbrl opened this issue Aug 6, 2020 · 12 comments · Fixed by #13470
Closed
2 of 7 tasks

Panic in git blame #12440

sbrl opened this issue Aug 6, 2020 · 12 comments · Fixed by #13470
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Milestone

Comments

@sbrl
Copy link

sbrl commented Aug 6, 2020

  • 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
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • 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)

@lunny lunny added the type/bug label Aug 6, 2020
@stale
Copy link

stale bot commented Oct 12, 2020

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.

@stale stale bot added the issue/stale label Oct 12, 2020
@6543
Copy link
Member

6543 commented Oct 12, 2020

looks like at

blamePart.Lines = append(blamePart.Lines, code)

blamePart == nil <- witch should not be the case ...

@stale stale bot removed the issue/stale label Oct 12, 2020
@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Oct 12, 2020
@6543
Copy link
Member

6543 commented Oct 12, 2020

@6543 6543 added this to the 1.12.6 milestone Oct 12, 2020
@lafriks lafriks modified the milestones: 1.12.6, 1.13.0 Oct 15, 2020
@42wim
Copy link
Member

42wim commented Oct 17, 2020

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.

42wim added a commit to 42wim/gitea that referenced this issue Oct 17, 2020
@mappu

This comment has been minimized.

@zeripath

This comment has been minimized.

@mappu

This comment has been minimized.

@AlrikG
Copy link

AlrikG commented Oct 31, 2020

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

@lafriks
Copy link
Member

lafriks commented Oct 31, 2020

This is not fixed yet

zeripath added a commit to zeripath/gitea that referenced this issue Nov 8, 2020
6543 pushed a commit to 6543-forks/gitea that referenced this issue Nov 9, 2020
6543 pushed a commit to 6543-forks/gitea that referenced this issue Nov 9, 2020
techknowlogick added a commit that referenced this issue Nov 10, 2020
techknowlogick added a commit to techknowlogick/gitea that referenced this issue Nov 10, 2020
techknowlogick added a commit to techknowlogick/gitea that referenced this issue Nov 10, 2020
@lafriks lafriks modified the milestones: 1.13.0, 1.12.6 Nov 10, 2020
zeripath added a commit that referenced this issue Nov 10, 2020
zeripath added a commit that referenced this issue Nov 10, 2020
@sbrl
Copy link
Author

sbrl commented Nov 10, 2020

Thanks, everyone for fixing this :D

@zeripath
Copy link
Contributor

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

@zeripath
Copy link
Contributor

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

@go-gitea go-gitea locked and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants