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

Stack overflow in UploadPack #1062

Open
icyphox opened this issue Mar 26, 2024 · 2 comments
Open

Stack overflow in UploadPack #1062

icyphox opened this issue Mar 26, 2024 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@icyphox
Copy link

icyphox commented Mar 26, 2024

Hi,

I'm running into a stack overflow when plumbing/transport/server.(*upSession).UploadPack gets called. Here's the traceback:

goroutine 3250208 [running]:
github.com/go-git/go-git/v5/storage/filesystem.(*deltaObject).Type(0xc000a61c80?)
        <autogenerated>:1 +0x34 fp=0xc020f20378 sp=0xc020f20370 pc=0x7bbdf4
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).fixAndBreakChainsOne(0x9bb780?, 0xc040f1fc60?, 0xc000abbe60)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:152 +0x31 fp=0xc020f203e0 sp=0xc020f20378 pc=0x799971
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).fixAndBreakChainsOne(0x9bb780?, 0xc040f1fc60?, 0xc00060a6c0)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:177 +0xc5 fp=0xc020f20448 sp=0xc020f203e0 pc=0x799a05
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).fixAndBreakChainsOne(0x9bb780?, 0xc040f1fc60?, 0xc000abbe60)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:177 +0xc5 fp=0xc020f204b0 sp=0xc020f20448 pc=0x799a05
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).fixAndBreakChainsOne(0x9bb780?, 0xc040f1fc60?, 0xc00060a6c0)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:177 +0xc5 fp=0xc020f20518 sp=0xc020f204b0 pc=0x799a05

... snip ...

        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:143 +0x17a fp=0xc040f1fd90 sp=0xc040f1fc08 pc=0x7998da
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).objectsToPack(0xc00036da60, {0xc000a80000?, 0x15a3, 0x24f44eb48?}, 0xa)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:116 +0x245 fp=0xc040f1fe38 sp=0xc040f1fd90 pc=0x799625
github.com/go-git/go-git/v5/plumbing/format/packfile.(*deltaSelector).ObjectsToPack(0xc00036da60, {0xc000a80000, 0x15a3, 0x1b33}, 0xa)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/delta_selector.go:40 +0x85 fp=0xc040f1ff28 sp=0xc040f1fe38 pc=0x798d85
github.com/go-git/go-git/v5/plumbing/format/packfile.(*Encoder).Encode(0xc0007e4f00, {0xc000a80000?, 0x6d27a8?, 0xc00011a240?}, 0xb42f40?)
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/format/packfile/encoder.go:53 +0x36 fp=0xc040f1ff88 sp=0xc040f1ff28 pc=0x79be56
github.com/go-git/go-git/v5/plumbing/transport/server.(*upSession).UploadPack.func1()
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/transport/server/server.go:173 +0x31 fp=0xc040f1ffe0 sp=0xc040f1ff88 pc=0x877431
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc040f1ffe8 sp=0xc040f1ffe0 pc=0x46b1c1
created by github.com/go-git/go-git/v5/plumbing/transport/server.(*upSession).UploadPack in goroutine 3250206
        /home/icy/go/pkg/mod/github.com/go-git/go-git/v5@v5.11.0/plumbing/transport/server/server.go:171 +0x456

Any pointers on why this occurs? A cursory peek at the code base and I see a recursive call to fixAndBreakChainsOne here:

if err := dw.fixAndBreakChainsOne(objectsToPack, base); err != nil {

@pjbgf pjbgf added bug Something isn't working help wanted Extra attention is needed labels Apr 11, 2024
@pjbgf
Copy link
Member

pjbgf commented Apr 11, 2024

@icyphox would you be able to provide some steps to reproduce? Is the repository public being used public?

@icyphox
Copy link
Author

icyphox commented Apr 12, 2024

Hi, reproducing is something I'm struggling with since the cause seems almost magical. It either happens 3–4 times a day or sometimes weeks go by without it crashing. The code is public: https://github.com/icyphox/legit/blob/21627fed77b003cdcb6daa4c682a841184880028/routes/git.go#L95

For what it's worth, the system this is being deployed on is OpenBSD amd64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants