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

Gitea 1.5.0 fails to run (segfaults) #4692

Closed
3 of 7 tasks
tgurr opened this issue Aug 13, 2018 · 18 comments · Fixed by #5994
Closed
3 of 7 tasks

Gitea 1.5.0 fails to run (segfaults) #4692

tgurr opened this issue Aug 13, 2018 · 18 comments · Fixed by #5994
Labels
status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/bug

Comments

@tgurr
Copy link
Contributor

tgurr commented Aug 13, 2018

  • Gitea version (or commit ref): 1.5.0
  • Git version: 2.18.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
  • Log gist:
Aug 13 15:39:19 localhost systemd[1]: Started Gitea (Git with a cup of tea).
Aug 13 15:39:19 localhost gitea[23535]: panic: runtime error: invalid memory address or nil pointer dereference
Aug 13 15:39:19 localhost gitea[23535]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x7be913]
Aug 13 15:39:19 localhost gitea[23535]: goroutine 1 [running]:
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).transformValue(0xc4202d2ea0, 0xc4202cc691, 0x28, 0xc4204cce48, 0x4ac519)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:123 +0xa3
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).String(0xc4202d2ea0, 0xc4202cb320, 0x15)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:130 +0x3d
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).MustString(0xc4202d2ea0, 0xc4202cb320, 0x15, 0x1, 0xc4202cb320)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:202 +0x2f
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/modules/setting.NewContext()
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/modules/setting/setting.go:1151 +0x4526
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/routers.GlobalInit()
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/routers/init.go:47 +0x4a
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/cmd.runWeb(0xc42036ea00, 0x0, 0x0)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/cmd/web.go:83 +0xa8
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0x10846a0, 0x1270720, 0xc42036ea00, 0xc420094e00, 0x0)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0xad
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(0x1217d01, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x123677a, 0x16, 0x0, ...)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:191 +0xa0e
Aug 13 15:39:19 localhost gitea[23535]: code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0xc42001a340, 0xc4200b4040, 0x4, 0x4, 0x0, 0x0)
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:241 +0x5b8
Aug 13 15:39:19 localhost gitea[23535]: main.main()
Aug 13 15:39:19 localhost gitea[23535]:         /var/tmp/paludis/build/net-gitea-1.5.0/work/build/src/code.gitea.io/gitea/main.go:52 +0x40e
Aug 13 15:39:19 localhost systemd[1]: gitea.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Aug 13 15:39:19 localhost systemd[1]: gitea.service: Failed with result 'exit-code'.

Description

Trying to run 1.5.0 after compiling using go 1.10.3 results in the following error message. Compiling and running the previous Gitea 1.4.3 with the same options works fine. I ran into this when trying to upgrade an instance with 1.4.3 to 1.5.0, but it's also reproducible on another host with no previous Gitea installation/configuration/data present.

@lafriks
Copy link
Member

lafriks commented Aug 13, 2018

Can you provide app.ini you are using as it seems to be problem in it.

@rbong
Copy link

rbong commented Aug 14, 2018

I am getting the same error with 1.5.0. If I don't comment out either of the last two lines from app.ini, which I pulled from app.ini.example.

[U2F]
APP_ID = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
TRUSTED_FACETS = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/

@tgurr
Copy link
Contributor Author

tgurr commented Aug 14, 2018

Commenting out the [U2F] section does the trick or me as well, thanks @rbong.

@eripa
Copy link

eripa commented Aug 19, 2018

Same for me. Segfaulting unless I remove the U2F section. U2F still works with it removed though.. so maybe it's no longer needed?

@lafriks
Copy link
Member

lafriks commented Aug 19, 2018

If removed it gitea uses defaults as given in sample app.ini file

@eripa
Copy link

eripa commented Aug 19, 2018

Ok. This is the one I had:

[U2F]
APP_ID = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s
TRUSTED_FACETS = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s

I grabbed the U2F section from here: https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample#L630

(the only difference was that it had trailing / on each setting)

and added that instead of nothing and it got back into segfaulting. There seems to be a difference between having this configured at all and just leaving it out.

@lafriks
Copy link
Member

lafriks commented Aug 19, 2018

I think that / at the end is critical

@eripa
Copy link

eripa commented Aug 19, 2018 via email

@rain0r
Copy link

rain0r commented Oct 11, 2018

Edit: Downgrading to 1.4.3 fixed the issue.

I'm experiencing the same error since upgrading to gitea-1.5.2.

Gitea version (or commit ref): 1.5.2
Git version: 2.19.1
Operating system: Gentoo Linux
Database: PostgreSQL 10.5

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x7f3654]

goroutine 1 [running]:
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).transformValue(0xc0002afc20, 0xc000041861, 0x28, 0xc0004eee70, 0x4af6f9)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:123 +0xa4
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).String(0xc0002afc20, 0xc0002ad320, 0x14)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:130 +0x3d
code.gitea.io/gitea/vendor/gopkg.in/ini%2ev1.(*Key).MustString(0xc0002afc20, 0xc0002ad320, 0x14, 0x1, 0xc0002ad320)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/gopkg.in/ini.v1/key.go:202 +0x2f
code.gitea.io/gitea/modules/setting.NewContext()
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/modules/setting/setting.go:1151 +0x45f4
code.gitea.io/gitea/routers.GlobalInit()
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/routers/init.go:47 +0x4a
code.gitea.io/gitea/cmd.runWeb(0xc00032e8c0, 0x0, 0x0)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/cmd/web.go:83 +0xaa
code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0x12e1b80, 0x14dc4f0, 0xc00032e8c0, 0xc0000a9800, 0x0)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0xad
code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(0x146aae8, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1490463, 0x16, 0x0, ...)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:191 +0x96d
code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0xc0002844e0, 0xc0000aa040, 0x4, 0x4, 0x0, 0x0)
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:241 +0x5a2
main.main()
        /var/tmp/portage/www-apps/gitea-1.5.2/work/gitea-1.5.2/src/code.gitea.io/gitea/main.go:52 +0x3a7

@lunny
Copy link
Member

lunny commented Oct 11, 2018

It seems it's a upstream library gopkg.in/ini.v1's bug.

@lafriks lafriks added the status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR label Oct 14, 2018
@stefangweichinger
Copy link

I also see gitea-1.5.2 fail with the U2F-section in app.ini ... and initially I added that section because adding my U2F-key (yubikey) does not work. The button "Add Security Key" does nothing here.

The URL /user/settings/security/u2f/request_register fails ... according to the 404 mentioned in my dev-tools (chrome).

@ArchangeGabriel
Copy link

Still present with 1.6.0.

@lafriks lafriks mentioned this issue Nov 26, 2018
7 tasks
@mckaygerhard
Copy link

still present at 1.5.3 and 1.6.0, still present at master!, similar as #5526 but not same, in that issue i talk about more pointed debug messages at errors

@mckaygerhard
Copy link

today still at 1.6.2 U2F Block In app.ini Causes A Segfault

@alyandon
Copy link

alyandon commented Jan 10, 2019

Looks like the problem is that PROTOCOL, DOMAIN and HTTP_PORT keys are not declared in the U2F section of the example file so the ini parser (see line 120 of transformValue() in key.go) falls back to looking for those keys in the DEFAULT section, ignores the returned error and blindly continues with the assumption that they must have been found instead of actually verifying that they were found.

I'm not sure what the expected behavior of the ini parser is but it should be easy enough to define those keys in the sample ini file in the default or U2F sections to avoid the panic on startup.

@mckaygerhard
Copy link

well by defining those keys or remove the sectin solves the situation, but:
yeah, now 1.7.X development and bug still present .. seems 1.6.X are default stable and the bugs its the real stable and here definitivelly

@jonasfranz
Copy link
Member

A solution might be to remove the U2F section from the example config since this section is only required by a small minority of people using Gitea on multiple domains. The documentation will stay in the config cheat sheet.

@alyandon
Copy link

Someone should put together a minimal test case and report the issue upstream. I took a peek at their repository and they seem to be willing to fix issues but no one appears to have reported this particular panic.

The example config needs to change regardless because the most sane thing for upstream to do would be to return an error instead of panicking which would still stop gitea from starting up. At least, I wouldn't want gitea to start up if the config it is using has errors.

Gottox added a commit to void-linux/void-packages that referenced this issue Feb 2, 2019
remove U2F section from config file due to a bug in the config
parser[1].

[1] go-gitea/gitea#4692
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.