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

Error 500 when viewing a commit by its ID #23872

Closed
a20eac1d opened this issue Apr 2, 2023 · 5 comments · Fixed by #23885
Closed

Error 500 when viewing a commit by its ID #23872

a20eac1d opened this issue Apr 2, 2023 · 5 comments · Fixed by #23885
Labels
Milestone

Comments

@a20eac1d
Copy link

a20eac1d commented Apr 2, 2023

Description

When trying to view commits by their ID, Gitea sometimes crashes and shows an "Error 500" page.

I can make this issue appear very reliably when I have multiple requests open at the same time (click on multiple commit IDs in short time) or if I abort the current page load and then reload it immediately. It seems like the previous request is still going on the server and the new request is messing it up.

The error:

An error occurred:

template: repo/diff/section_unified:32:28: executing "repo/diff/section_unified" at <$section.GetComputedInlineDiffFor>: error calling GetComputedInlineDiffFor: runtime error: slice bounds out of range [2:1]

Gitea Version: 1.19.0

Gitea Version

1.19.0

Can you reproduce the bug on the Gitea demo site?

YES! See comment below

Log Gist

Updated Gist with more info:

https://gist.github.com/a20eac1d/4f2037bdfe147d2ad8c7ea375724f72a

Screenshots

https://i.imgur.com/BDd2x90.png

Git Version

2.38.4, Wire Protocol Version 2 Enabled

Operating System

Ubuntu 22.04 LTS

How are you running Gitea?

Gitea is running in a Docker container, created with the official tutorial at: https://docs.gitea.io/en-us/install-with-docker/

Database

SQLite

@a20eac1d a20eac1d changed the title Error 500 when vieweing a commit by its ID Error 500 when viewing a commit by its ID Apr 2, 2023
@lunny
Copy link
Member

lunny commented Apr 2, 2023

Is your patch a public one? Could you upload it to help the investigation?

@a20eac1d
Copy link
Author

a20eac1d commented Apr 2, 2023

@lunny Sorry, what do you mean by patch?

@a20eac1d
Copy link
Author

a20eac1d commented Apr 2, 2023

This bug appears to be a regression. When I downgrade my Gitea instance back to 1.18.0 (with the exact same settings) I cannot reproduce this issue. Upgrading to 1.19.0 again causes it to happen.

@a20eac1d
Copy link
Author

a20eac1d commented Apr 2, 2023

@lunny

I was able to re-produce this issue on the official Gitea demo site. It is much more difficult to make it happen on there and it is super easy for me to reproduce on my local instance, so I believe the available CPU power has something to do with it.

Check out this repository: https://try.gitea.io/a20eac1d/bug1190/commits/branch/main

Under the SHA1 header you can find a button that says "f8269d2a24". Pressing this will take you to that specific commit. You need to press that button with your middle mouse button 5-15 times so that you have many tabs open trying to load that commit at the same time. If you are lucky, at some point at least one of those tabs will crash with an "Error 500". This happens rarely on a powerful instance like the Gitea demo, but it happens extremely often on my local instance which has less CPU power available. This does not happen on 1.18.0 and it only started happening in 1.19.0

@wxiaoguang
Copy link
Contributor

Thank you for your detailed report! It helps a lot.

I think it could be fixed by Fix cases.Title crash for concurrency #23885

#21814 was introduced by 1.19, it makes the compare page crashes more than before.

@lunny lunny added this to the 1.19.1 milestone Apr 3, 2023
jolheiser pushed a commit that referenced this issue Apr 3, 2023
Regression of #19676 and #21814

Fix #23872

`cases.Title` is not thread-safe, it has internal state, so it can't be
used as a global shared variable.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Apr 3, 2023
Regression of go-gitea#19676 and go-gitea#21814

Fix go-gitea#23872

`cases.Title` is not thread-safe, it has internal state, so it can't be
used as a global shared variable.
6543 pushed a commit that referenced this issue Apr 3, 2023
Backport #23885 by @wxiaoguang

Regression of #19676 and #21814

Fix #23872

`cases.Title` is not thread-safe, it has internal state, so it can't be
used as a global shared variable.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2023
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.

3 participants