Girbons / comics-downloader

tool to download comics and manga in pdf/epub/cbr/cbz from a website
MIT License
457 stars 49 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #44

Closed PreownedFIN closed 4 years ago

PreownedFIN commented 4 years ago

Hi!

I encountered this error when downloading many chapters at once. This particular one got up to 65 chapters, on other 'runs' it would panic somewhere between 30-50 chapters.

Here's the command I used: .\comics-downloader.exe -url https://mangadex.org/title/22369/jahy-sama-wa-kujikenai -output "T:\Manga\Jahy-sama Won't Be Discouraged!" -format epub

(The output is on a mapped network drive, not sure if relevant, but hey.)

  36% |██████████████                          |  [3s:5s]panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x670e20]

goroutine 1 [running]:
image/jpeg.Encode(0x900ec0, 0xc000154000, 0x0, 0x0, 0x0, 0x3, 0x900c80)
        /usr/local/Cellar/go/1.13/libexec/src/image/jpeg/writer.go:576 +0x30
github.com/Girbons/comics-downloader/pkg/util.SaveImage(0x900ec0, 0xc000154000, 0x16a0028, 0xc000188500, 0x869d60, 0x3, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/util/util.go:171 +0x228
github.com/Girbons/comics-downloader/pkg/core.(*Comic).DownloadImages(0xc000142b40, 0xc00000c3c0, 0x28, 0x0, 0x0, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:293 +0x64d
github.com/Girbons/comics-downloader/pkg/core.(*Comic).makeEPUB(0xc000142b40, 0xc00000c3c0, 0x28, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:96 +0x23a
github.com/Girbons/comics-downloader/pkg/core.(*Comic).MakeComic(0xc000142b40, 0xc00000c3c0, 0x28, 0xc0003b8630, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:318 +0xee
github.com/Girbons/comics-downloader/cmd/app.download(0xc00000e380, 0x37, 0xc00000a118, 0x4, 0x0, 0x0, 0x0, 0x869d60, 0x3, 0xc00000c3c0, ...)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/app/downloader.go:76 +0x4d9
github.com/Girbons/comics-downloader/cmd/app.Run(0xc00000e380, 0x37, 0xc00000a118, 0x4, 0x0, 0x0, 0x869d60, 0x3, 0x0, 0x258, ...)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/app/downloader.go:111 +0x1e1
main.main()
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/downloader/main.go:44 +0x5a2

I can still download all of the chapters by restarting the download with the same command, but it is a bother still. Thanks for the nifty scraper though!

Girbons commented 4 years ago

Hi @PreownedFIN,

Thanks for reporting!

It fails after a while or with a specific chapter?

I encountered this error when downloading many chapters at once. This particular one got up to 65 chapters, on other 'runs' it would panic somewhere between 30-50 chapters.

I'll try to investigate in the weekend 👍

Kevman323 commented 4 years ago

I'm finding the same bug. Randomly crashes with the same bug. When this happens, it leaves a 0kb jpg file in the images folder, which luckily gets re-downloaded and fixed when the script is run again.

It's probably the same, but here's my log.

/home/mainuser/apps/comics-downloader/comics-downloader --all -country gb -format cbr -output "/home/mainuser/storage/local" https://mangadex.org/title/36329/useless-ponko

  19% |███████                                 |  [0s:3s]panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x677149]

goroutine 1 [running]:
image/jpeg.Encode(0x8f52e0, 0xc000270000, 0x0, 0x0, 0x0, 0x3, 0x8f5a80)
        /usr/local/Cellar/go/1.13/libexec/src/image/jpeg/writer.go:576 +0x29
github.com/Girbons/comics-downloader/pkg/util.SaveImage(0x8f52e0, 0xc000270000, 0x7f08d1408930, 0xc000393900, 0x85d70c, 0x3, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/util/util.go:171 +0x221
github.com/Girbons/comics-downloader/pkg/core.(*Comic).DownloadImages(0xc0000102d0, 0x7fffc433e7cb, 0x1c, 0x0, 0x0, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:259 +0x616
github.com/Girbons/comics-downloader/pkg/core.(*Comic).makeCBRZ(0xc0000102d0, 0x7fffc433e7cb, 0x1c, 0x0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:169 +0x93
github.com/Girbons/comics-downloader/pkg/core.(*Comic).MakeComic(0xc0000102d0, 0x7fffc433e7cb, 0x1c, 0xc000010ab0, 0x0)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/pkg/core/core.go:286 +0x62
github.com/Girbons/comics-downloader/cmd/app.download(0xc0000161e0, 0x2f, 0x7fffc433e7bf, 0x3, 0x7fffc433e7b4, 0x2, 0x1, 0x85d70c, 0x3, 0x7fffc433e7cb, ...)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/app/downloader.go:83 +0x6e6
github.com/Girbons/comics-downloader/cmd/app.Run(0xc0000161e0, 0x2f, 0x7fffc433e7bf, 0x3, 0x7fffc433e7b4, 0x2, 0x85d70c, 0x3, 0x1, 0x258, ...)
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/app/downloader.go:118 +0x1da
main.main()
        /Users/girbons/go/src/github.com/Girbons/comics-downloader/cmd/downloader/main.go:44 +0x59b
Girbons commented 4 years ago

Sorry guys for the delay, I probably have found a possible fix that I'm going to release soon.

Girbons commented 4 years ago

@PreownedFIN @Kevman323 could you please try this version?