Error 500 when viewing some of repo's subdirectories #3286

Closed
opened 2025-11-02 05:06:35 -06:00 by GiteaMirror · 18 comments
Owner

Originally created by @achikhv on GitHub (May 2, 2019).

  • Gitea version (or commit ref): 1.7.6
  • Git version: 2.19.1.1
  • Operating system: Windows Server 2008 R2
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • [ X] MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • [ X] No
    • Not relevant
  • Log gist:

Description

I get error 500 when I try to view contents of some directories inside my repo. One subdirs are opened successfully but another gives an error. I can not find any quick reason to it.
All subdirs have simple names with only ASCII encoding, no special symbols or spaces.

In my gitea.log I see:

2019/05/03 09:01:08 [...routers/repo/view.go:55 renderDirectory()] [E] GetCommitsInfo: exit status 3221225725 

For example I get 500 when I follow:
http://sc.lers.ru/LersUchet/LersUchet/src/branch/master/Client
But following http://sc.lers.ru/LersUchet/LersUchet/src/branch/master/Server works as expected.

Originally created by @achikhv on GitHub (May 2, 2019). - Gitea version (or commit ref): 1.7.6 - Git version: 2.19.1.1 - Operating system: Windows Server 2008 R2 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ X] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ X] No - [ ] Not relevant - Log gist: ## Description I get error 500 when I try to view contents of some directories inside my repo. One subdirs are opened successfully but another gives an error. I can not find any quick reason to it. All subdirs have simple names with only ASCII encoding, no special symbols or spaces. In my gitea.log I see: ``` 2019/05/03 09:01:08 [...routers/repo/view.go:55 renderDirectory()] [E] GetCommitsInfo: exit status 3221225725 ``` For example I get 500 when I follow: http://sc.lers.ru/LersUchet/LersUchet/src/branch/master/Client But following http://sc.lers.ru/LersUchet/LersUchet/src/branch/master/Server works as expected.
GiteaMirror added the type/bug label 2025-11-02 05:06:35 -06:00
Author
Owner

@lafriks commented on GitHub (May 5, 2019):

Can you reproduce this on try.gitea.io?

@lafriks commented on GitHub (May 5, 2019): Can you reproduce this on try.gitea.io?
Author
Owner

@achikhv commented on GitHub (May 6, 2019):

Unfortunately no. I can't upload my repo as it is commercial software. This repo is quite big - over 500MB in size and has 35K commits over last 7 years , so it is hard to reproduce it.

Also I get 500 with same error code when I try to view some old commits by SHA-1.

2019/05/06 14:17:22 [...uters/repo/commit.go:196 Diff()] [E] Repo.GitRepo.GetCommit: exit status 3221225725

Not a big deal for me anyway, but it's quite strange.

@achikhv commented on GitHub (May 6, 2019): Unfortunately no. I can't upload my repo as it is commercial software. This repo is quite big - over 500MB in size and has 35K commits over last 7 years , so it is hard to reproduce it. Also I get 500 with same error code when I try to view some old commits by SHA-1. ``` 2019/05/06 14:17:22 [...uters/repo/commit.go:196 Diff()] [E] Repo.GitRepo.GetCommit: exit status 3221225725 ``` Not a big deal for me anyway, but it's quite strange.
Author
Owner

@zeripath commented on GitHub (May 27, 2019):

Hmm... Two possible encoding problems come to mind:

  • Do you have filenames in client that are not in UTF-8 encoding?
  • Does client have commit messages that are not in UTF-8 encoding?

Git internally just thinks of filenames as a byte array of non NULs and likely we're just enforcing UTF-8 on that because that's the most likely case. Similarly for the commit messages but AFAIU there's supposed to be an encoding marker for these - which I also suspect we're ignoring.

@zeripath commented on GitHub (May 27, 2019): Hmm... Two possible encoding problems come to mind: * Do you have filenames in client that are not in UTF-8 encoding? * Does client have commit messages that are not in UTF-8 encoding? Git internally just thinks of filenames as a byte array of non NULs and likely we're just enforcing UTF-8 on that because that's the most likely case. Similarly for the commit messages but AFAIU there's supposed to be an encoding marker for these - which I also suspect we're ignoring.
Author
Owner

@achikhv commented on GitHub (May 28, 2019):

  1. No, all source file names are in ASCII encoding.
  2. Right now all commit messages are encoded UTF-8 by default. Initially it was SVN repo, so I suppose that during migration "git svn" should have used UTF-8 by default too.

Anyway I can't be sure about it. In this comment I pointed that 500 occurs when viewing older commits, so maybe it is commit encoding that causes 500.

@achikhv commented on GitHub (May 28, 2019): 1. No, all source file names are in ASCII encoding. 2. Right now all commit messages are encoded UTF-8 by default. Initially it was SVN repo, so I suppose that during migration "git svn" should have used UTF-8 by default too. Anyway I can't be sure about it. In [this comment](https://github.com/go-gitea/gitea/issues/6837#issuecomment-489497001) I pointed that 500 occurs when viewing older commits, so maybe it is commit encoding that causes 500.
Author
Owner

@zeripath commented on GitHub (May 28, 2019):

Ok that's good to know. I think there are some Chinese users who have used big5 as their commit messages too and are also having problems.

https://www.git-tower.com/help/mac/faq-and-tips/faq/encoding

Might be of some help.

@zeripath commented on GitHub (May 28, 2019): Ok that's good to know. I think there are some Chinese users who have used big5 as their commit messages too and are also having problems. https://www.git-tower.com/help/mac/faq-and-tips/faq/encoding Might be of some help.
Author
Owner

@zeripath commented on GitHub (May 28, 2019):

In particular:

git log -1 --pretty='format:%h: "%B" (Encoding: "%e")' SHA

Which is just for testing one commit's stored encoding but should be extendable to look at all or a particular file.

Now iirc svn is actually quite good at dealing with encodings - so I expect that the encoding will be stored rather than just the data being dumped in the message, however it may not be. If it's the first case that should be relatively easy to fix - assuming go git handles this correctly. If it's the second case well that's more difficult but again should be solvable.

If you could find a commit which doesn't have the utf8 encoding that would be good to know.

@zeripath commented on GitHub (May 28, 2019): In particular: ``` git log -1 --pretty='format:%h: "%B" (Encoding: "%e")' SHA ``` Which is just for testing one commit's stored encoding but should be extendable to look at all or a particular file. Now iirc svn is actually quite good at dealing with encodings - so I expect that the encoding will be stored rather than just the data being dumped in the message, however it may not be. If it's the first case that should be relatively easy to fix - assuming go git handles this correctly. If it's the second case well that's more difficult but again should be solvable. If you could find a commit which doesn't have the utf8 encoding that would be good to know.
Author
Owner

@zeripath commented on GitHub (May 28, 2019):

Oh would it be possible to check this is still a problem on master? We made substantial changes to our git infrastructure between 1.7 and 1.9 so it would be good to know if it's still a problem.

You certainly should move off 1.7.6 though.

@zeripath commented on GitHub (May 28, 2019): Oh would it be possible to check this is still a problem on master? We made substantial changes to our git infrastructure between 1.7 and 1.9 so it would be good to know if it's still a problem. You certainly should move off 1.7.6 though.
Author
Owner

@achikhv commented on GitHub (May 29, 2019):

Hello!

I have already upgraded to the latest 1.8.1 and 500 is still there.

All commits in my repo are encoded UTF-8 , ie "Encoding: %e" shows empty string **Encoding: ** As I understand it defaults to UTF-8.

@achikhv commented on GitHub (May 29, 2019): Hello! I have already upgraded to the latest 1.8.1 and 500 is still there. All commits in my repo are encoded UTF-8 , ie "Encoding: %e" shows empty string **Encoding: ** As I understand it defaults to UTF-8.
Author
Owner

@zeripath commented on GitHub (May 29, 2019):

I was meaning master not 1.8.

The lack of encoding headers doesn't rule out misencoded commits, it just means that we're unlikely to be able to easily fix them without catching an error first. But it does make it less likely.

Are you able to find the commit that causes the 500? It sounds like you know a SHA that causes the problem. Is there anything at all you can tell me about that SHA that might help?

@zeripath commented on GitHub (May 29, 2019): I was meaning master not 1.8. The lack of encoding headers doesn't rule out misencoded commits, it just means that we're unlikely to be able to easily fix them without catching an error first. But it does make it less likely. Are you able to find the commit that causes the 500? It sounds like you know a SHA that causes the problem. Is there anything at all you can tell me about that SHA that might help?
Author
Owner

@achikhv commented on GitHub (May 29, 2019):

Sorry, right now I can't try master, because it's preferable to stay on stable release.

Actually all commits that was made earlier than 04.07.2016 causes 500. I know last commit causing 500. There is nothing special about it, only couple of line changes in one file. No moves or renames.

What particular information about this commit would you like to know?

@achikhv commented on GitHub (May 29, 2019): Sorry, right now I can't try master, because it's preferable to stay on stable release. Actually all commits that was made earlier than 04.07.2016 causes 500. I know last commit causing 500. There is nothing special about it, only couple of line changes in one file. No moves or renames. What particular information about this commit would you like to know?
Author
Owner

@zeripath commented on GitHub (May 29, 2019):

Hmm. I'm trying to work out how to get the information without you revealing your internal data. I'm guessing that the commit message is not in English but likely in Russian - my suspicion is still that the message is not stored as utf8 even though it claims it is.

Basically I would like to check that the commit and the tree make sense.

git show --format=raw $SHA should show us the commit raw but what we want is to definitely prove that its message is in utf8 rather than Windows-1251 or iso-8859-5.

In some ways without being able to check whether this bug is still present on master means that we don't know if it's fixed already.

@zeripath commented on GitHub (May 29, 2019): Hmm. I'm trying to work out how to get the information without you revealing your internal data. I'm guessing that the commit message is not in English but likely in Russian - my suspicion is still that the message is not stored as utf8 even though it claims it is. Basically I would like to check that the commit and the tree make sense. `git show --format=raw $SHA` should show us the commit raw but what we want is to definitely prove that its message is in utf8 rather than Windows-1251 or iso-8859-5. In some ways without being able to check whether this bug is still present on master means that we don't know if it's fixed already.
Author
Owner

@BNolet commented on GitHub (Jul 12, 2019):

Having a similar problem myself, using MySQL as the DB though. Running on v799f5e0.

Can't view here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes/hello-friend-ng
But can view here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes

There's a README.md in the folder, yes, but I am able to view the file directly here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes/hello-friend-ng/README.md

Haven't done much troubleshooting yet, but if I find anything interesting I'll post here. Feel free to download and mirror the source.

@BNolet commented on GitHub (Jul 12, 2019): Having a similar problem myself, using MySQL as the DB though. Running on v799f5e0. Can't view here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes/hello-friend-ng But can view here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes There's a README.md in the folder, yes, but I am able to view the file directly here: https://gitea.bnolet.me/brandon/personal-blog/src/branch/master/themes/hello-friend-ng/README.md Haven't done much troubleshooting yet, but if I find anything interesting I'll post here. Feel free to download and mirror the source.
Author
Owner

@lunny commented on GitHub (Jul 13, 2019):

@BNolet I mirrored your repo to local and https://gitea.com/lunny/test-personal-blog/src/branch/master/themes/hello-friend-ng , but it's OK. Is your database setting as utf8mb4?

@lunny commented on GitHub (Jul 13, 2019): @BNolet I mirrored your repo to local and https://gitea.com/lunny/test-personal-blog/src/branch/master/themes/hello-friend-ng , but it's OK. Is your database setting as utf8mb4?
Author
Owner

@BNolet commented on GitHub (Jul 15, 2019):

@lunny Strange! I didn't actively change the encoding for the DB and looking at some threads, it doesn't seem that's the default either, so I'm inclined to say no

@BNolet commented on GitHub (Jul 15, 2019): @lunny Strange! I didn't actively change the encoding for the DB and looking at some threads, it doesn't seem that's the default either, so I'm inclined to say no
Author
Owner

@BNolet commented on GitHub (Jul 15, 2019):

The following is from the logs at the moment where I get a 500 error code:

2019/07/15 15:13:32 [...les/context/panic.go:36 1()] [E] PANIC:: runtime error: slice bounds out of range
/usr/local/go/src/runtime/panic.go:54 (0x4340da)
/go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:176 (0x90b6e0)
/go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:280 (0x90c101)
/go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:232 (0x90bc3c)
/go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:133 (0x90ae03)
/go/src/code.gitea.io/gitea/routers/repo/view.go:52 (0x1226a16)
/go/src/code.gitea.io/gitea/routers/repo/view.go:437 (0x122befd)
/go/src/code.gitea.io/gitea/routers/repo/view.go:377 (0x122b69e)
/usr/local/go/src/reflect/value.go:447 (0x4cb940)
/usr/local/go/src/reflect/value.go:308 (0x4cb3c3)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x9a1266)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x9a0b5b)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x11661a8)
/go/src/code.gitea.io/gitea/modules/context/panic.go:40 (0x116619b)
/usr/local/go/src/reflect/value.go:447 (0x4cb940)
/usr/local/go/src/reflect/value.go:308 (0x4cb3c3)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x9a1266)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x9a0b5b)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9efc76)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/session/session.go:192 (0x9efc61)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:79 (0x9cfbc0)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9e177f)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/recovery.go:161 (0x9e176d)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:40 (0x9d39b3)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9e0aa0)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:52 (0x9e0a8b)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:40 (0x9d39b3)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20)
/go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:187 (0x9e29c6)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:303 (0x9dc435)
/go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/macaron.go:220 (0x9d4d8c)
/go/src/code.gitea.io/gitea/vendor/github.com/gorilla/context/context.go:141 (0xce32ca)
/usr/local/go/src/net/http/server.go:1995 (0x6f6213)
/usr/local/go/src/net/http/server.go:2774 (0x6f94e7)
/usr/local/go/src/net/http/server.go:1878 (0x6f51d0)
/usr/local/go/src/runtime/asm_amd64.s:1337 (0x464c60)
@BNolet commented on GitHub (Jul 15, 2019): The following is from the logs at the moment where I get a 500 error code: ``` 2019/07/15 15:13:32 [...les/context/panic.go:36 1()] [E] PANIC:: runtime error: slice bounds out of range /usr/local/go/src/runtime/panic.go:54 (0x4340da) /go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:176 (0x90b6e0) /go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:280 (0x90c101) /go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:232 (0x90bc3c) /go/src/code.gitea.io/gitea/vendor/code.gitea.io/git/commit_info.go:133 (0x90ae03) /go/src/code.gitea.io/gitea/routers/repo/view.go:52 (0x1226a16) /go/src/code.gitea.io/gitea/routers/repo/view.go:437 (0x122befd) /go/src/code.gitea.io/gitea/routers/repo/view.go:377 (0x122b69e) /usr/local/go/src/reflect/value.go:447 (0x4cb940) /usr/local/go/src/reflect/value.go:308 (0x4cb3c3) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x9a1266) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x9a0b5b) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x11661a8) /go/src/code.gitea.io/gitea/modules/context/panic.go:40 (0x116619b) /usr/local/go/src/reflect/value.go:447 (0x4cb940) /usr/local/go/src/reflect/value.go:308 (0x4cb3c3) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:177 (0x9a1266) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:137 (0x9a0b5b) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9efc76) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/session/session.go:192 (0x9efc61) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:79 (0x9cfbc0) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9e177f) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/recovery.go:161 (0x9e176d) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:40 (0x9d39b3) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:112 (0x9e0aa0) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:52 (0x9e0a8b) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/logger.go:40 (0x9d39b3) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:157 (0x9a0f20) /go/src/code.gitea.io/gitea/vendor/github.com/go-macaron/inject/inject.go:135 (0x9a0c4a) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/context.go:121 (0x9cfd19) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:187 (0x9e29c6) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/router.go:303 (0x9dc435) /go/src/code.gitea.io/gitea/vendor/gopkg.in/macaron.v1/macaron.go:220 (0x9d4d8c) /go/src/code.gitea.io/gitea/vendor/github.com/gorilla/context/context.go:141 (0xce32ca) /usr/local/go/src/net/http/server.go:1995 (0x6f6213) /usr/local/go/src/net/http/server.go:2774 (0x6f94e7) /usr/local/go/src/net/http/server.go:1878 (0x6f51d0) /usr/local/go/src/runtime/asm_amd64.s:1337 (0x464c60) ```
Author
Owner

@lunny commented on GitHub (Jul 15, 2019):

@BNolet It seems you have a version of v1.8.x or before.

@lunny commented on GitHub (Jul 15, 2019): @BNolet It seems you have a version of v1.8.x or before.
Author
Owner

@BNolet commented on GitHub (Jul 15, 2019):

welp, upgrade fixed the issue. I was running 1.8.0 upgraded to 1.10.

Thank you @lunny. I'll try to remember to upgrade before posting here next time

@BNolet commented on GitHub (Jul 15, 2019): welp, upgrade fixed the issue. I was running 1.8.0 upgraded to 1.10. Thank you @lunny. I'll try to remember to upgrade before posting here next time
Author
Owner

@achikhv commented on GitHub (Jul 15, 2019):

Yes, upgrade to 1.9.0 RC2 fixed issue.
Thanks!

@achikhv commented on GitHub (Jul 15, 2019): Yes, upgrade to 1.9.0 RC2 fixed issue. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3286