Zeno icon indicating copy to clipboard operation
Zeno copied to clipboard

PDF processing panic

Open CorentinB opened this issue 3 months ago • 3 comments

It seems to be happening in a very high concurrency load of processing PDFs. Hard to tell.

panic: runtime error: slice bounds out of range [-1:]
goroutine 5366 [running]:
github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model.skipStringLit({0xc00c60d800?, 0x1f06818?}, 0xc00c60d800?, 0x400?, 0x0?, 0xc00c60d800?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/model/parse.go:1273 +0xd4
github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model.skipCommentOrStringLiteral({0xc00c60d800?, 0x400?}, 0x1f06818?, 0x1?, 0x47e185?, 0xc5de26?, 0x0?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/model/parse.go:1302 +0x65
github.com/pdfcpu/pdfcpu/pkg/pdfcpu/model.DetectKeywordsWithContext({0x1f1c4c0, 0x291f7e0}, {0xc00c60d800?, 0x400?})
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/model/parse.go:1349 +0x1b2
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.buffer({0x1f1c4c0, 0x291f7e0}, {0x1f12ba0, 0xc0092d68a0})
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:1752 +0x191
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.parseXRefStream({0x1f1c4c0, 0x291f7e0}, 0xc014a5ab10, {0x1f12ba0?, 0xc0092d68a0?}, 0xc0137f0cc0, 0x0, 0x1)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:696 +0x12f
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.buildXRefTableStartingAt({0x1f1c4c0, 0x291f7e0}, 0xc014a5ab10, 0xc0137f0cc0)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:1606 +0x3c9
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.readXRefTable({0x1f1c4c0, 0x291f7e0}, 0xc014a5ab10)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:1643 +0x12e
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.ReadWithContext({0x1f1c4c0, 0x291f7e0}, {0x7fe6c82c40d0?, 0xc006509270?}, 0xc0137f0cb0?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:107 +0x1a5
github.com/pdfcpu/pdfcpu/pkg/pdfcpu.Read(...)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/pdfcpu/read.go:78
github.com/pdfcpu/pdfcpu/pkg/api.ReadContext({0x7fe6c82c40d0?, 0xc006509270?}, 0x7fe6a0606d40?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/api/api.go:74 +0x9f
github.com/pdfcpu/pdfcpu/pkg/api.ReadAndValidate({0x7fe6c82c40d0?, 0xc006509270?}, 0x42ff00?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/api/api.go:151 +0x1d
github.com/pdfcpu/pdfcpu/pkg/api.ReadValidateAndOptimize({0x7fe6c82c40d0?, 0xc006509270?}, 0xc00d6f6c60)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/api/api.go:179 +0x33
github.com/pdfcpu/pdfcpu/pkg/api.Annotations({0x7fe6c82c40d0?, 0xc006509270?}, {0x0, 0x0, 0x0}, 0x1000000012f71aa?)
        /home/corentin/go/pkg/mod/github.com/pdfcpu/[email protected]/pkg/api/annotation.go:39 +0x6d
github.com/REDACTED/Zeno/internal/pkg/postprocessor/extractor.PDFOutlinkExtractor.Extract({}, 0xc002aa5440?)
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/extractor/pdf.go:29 +0xa5
github.com/REDACTED/Zeno/internal/pkg/postprocessor.extractOutlinks(0xc002aa5560)
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/outlinks.go:64 +0x43d
github.com/REDACTED/Zeno/internal/pkg/postprocessor.postprocessItem(0xc002aa5560)
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/item.go:132 +0xac9
github.com/REDACTED/Zeno/internal/pkg/postprocessor.postprocess({0xc0016c8664, 0x4}, 0xc002aa5560)
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/postprocessor.go:143 +0x4a9
github.com/REDACTED/Zeno/internal/pkg/postprocessor.(*postprocessor).worker(0xc00015dd00, {0xc0016c8664, 0x4})
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/postprocessor.go:102 +0x5e5
created by github.com/REDACTED/Zeno/internal/pkg/postprocessor.Start.func1 in goroutine 1
        /home/corentin/custom/Zeno/internal/pkg/postprocessor/postprocessor.go:48 +0x10e

CorentinB avatar Sep 15 '25 11:09 CorentinB

https://github.com/pdfcpu/pdfcpu/issues/1193

yzqzss avatar Sep 15 '25 15:09 yzqzss

Looks like pdfcpu already fixed this, let's wait their next release.

yzqzss avatar Sep 16 '25 08:09 yzqzss

I'm also fine with pulling a commit in if it'll fix it.

NGTmeaty avatar Sep 16 '25 10:09 NGTmeaty