gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.87k stars 7.54k forks source link

Many fast git mv commands caused hugo server panic #10843

Open willfaught opened 1 year ago

willfaught commented 1 year ago

I have a bulk rename function:

177 function git-rename
178   for old_file in $argv[3..-1]
179     set new_file (echo $old_file | perl -pe "s/$argv[1]/$argv[2]/")
180     if test $old_file != $new_file
181       git mv $old_file $new_file
182     end
183   end
184 end

I ran it on 38 image files. I noticed some time later that it apparently caused hugo server to crash:

Change detected, rebuilding site.
2023-03-16 21:11:38.407 -0700
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/1.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/1-1.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/2.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/2-2.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/3.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/2-3.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/4.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/3-4.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/3-5.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/3-6.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/7.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/4-7.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/8.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/4-8.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/9.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/4-9.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/10.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/4-10.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/11.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5-11.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/12.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5-12.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/13.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5-13.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/14.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5-14.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/15.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/5-15.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/16.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-16.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/17.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-17.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/18.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-18.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/19.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-19.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/20.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-20.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/21.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/6-21.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/36.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/attire-flower-person-36.jpg"
Source changed CREATE        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/31.jpg"
Source changed RENAME        "/Users/Will/Developer/paige/exampleSite/content/shortcodes/gallery/cake-31.jpg"
panic: runtime error: slice bounds out of range [32:31]

goroutine 109575 [running]:
github.com/gohugoio/hugo/hugolib.(*pageState).deleteResource(...)
    github.com/gohugoio/hugo/hugolib/page.go:542
github.com/gohugoio/hugo/hugolib.(*pageState).renderResources.func1()
    github.com/gohugoio/hugo/hugolib/page.go:534 +0x50a
sync.(*Once).doSlow(0xc0005045f8?, 0x1000ac445?)
    sync/once.go:74 +0xc2
sync.(*Once).Do(...)
    sync/once.go:65
github.com/gohugoio/hugo/hugolib.(*pageState).renderResources(0xc006082200?)
    github.com/gohugoio/hugo/hugolib/page.go:502 +0x67
github.com/gohugoio/hugo/hugolib.pageRenderer(0xc0056ea460?, 0xc0088d7b00, 0xc0005047d0?, 0x10046b3c6?, 0xc0056f8300?)
    github.com/gohugoio/hugo/hugolib/site_render.go:114 +0xe7
created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages
    github.com/gohugoio/hugo/hugolib/site_render.go:74 +0x10

What version of Hugo are you using (hugo version)?

$ hugo env
hugo v0.111.3+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.20.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"
github.com/sass/dart-sass-embedded/protocol="1.2.0"
github.com/sass/dart-sass-embedded/compiler="1.59.2"
github.com/sass/dart-sass-embedded/implementation="1.59.2"

Does this issue reproduce with the latest release?

Yes

bep commented 1 year ago

Thanks. Yes, I have seen this myself -- and I have also fixed it in a branch that's taken me a little too long to get ready for merge.