Closed bao-huynh-ostv closed 1 year ago
I don't see any reference to go-fitz
in your crash. What is needed is a small reproducible code with problematic documents, not some description of what you are doing. Sorry, like it is nobody can help.
I don't see any reference to
go-fitz
in your crash. What is needed is a small reproducible code with problematic documents, not some description of what you are doing. Sorry, like it is nobody can help.
Hi @gen2brain , sorry for my missing code, i just updated the code
@bao-huynh-ostv How can I test and reproduce a snippet of code that is in the image? Why do you even think go-fitz is to blame when is not even mentioned in panic, can you try to get a gdb trace? As I said, what is needed here is a small reproducible code that will crash, not the whole of your project with a screenshot of some part of the fitz code that is proven to work and is the same as included tests.
Basically, does this code work or not for you, if not, the document you are using can possibly be useful:
package main
import (
"fmt"
"image/jpeg"
"os"
"path/filepath"
"github.com/gen2brain/go-fitz"
)
func main() {
doc, err := fitz.New("test.pdf")
if err != nil {
panic(err)
}
defer doc.Close()
tmpDir, err := os.MkdirTemp(os.TempDir(), "fitz")
if err != nil {
panic(err)
}
// Extract pages as images
for n := 0; n < doc.NumPage(); n++ {
img, err := doc.Image(n)
if err != nil {
panic(err)
}
f, err := os.Create(filepath.Join(tmpDir, fmt.Sprintf("test%03d.jpg", n)))
if err != nil {
panic(err)
}
err = jpeg.Encode(f, img, &jpeg.Options{jpeg.DefaultQuality})
if err != nil {
panic(err)
}
f.Close()
}
}
Hi @gen2brain, i try to use those code but it still got errors related to goroutine. It can only convert successfully 2 pages
signal 16 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag
runtime stack:
runtime.throw({0x10474b7a3?, 0x14000052000?})
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/panic.go:1047 +0x40 fp=0x140023d3440 sp=0x140023d3410 pc=0x1043ba360
runtime.sigNotOnStack(0x10)
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/signal_unix.go:1029 +0x5c fp=0x140023d3460 sp=0x140023d3440 pc=0x1043cf00c
runtime.adjustSignalStack(0x10, 0x14002400000, 0x140023d3508)
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/signal_unix.go:581 +0x250 fp=0x140023d34d0 sp=0x140023d3460 pc=0x1043ce340
runtime.sigtrampgo(0x10, 0x140023d3670, 0x140023d36d8)
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/signal_unix.go:469 +0x170 fp=0x140023d3550 sp=0x140023d34d0 pc=0x1043cdf90
runtime.sigtrampgo(0x10, 0x140023d3670, 0x140023d36d8)
<autogenerated>:1 +0x1c fp=0x140023d3580 sp=0x140023d3550 pc=0x1043e8acc
runtime.sigtramp()
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/sys_darwin_arm64.s:227 +0x4c fp=0x140023d3640 sp=0x140023d3580 pc=0x1043e7cbc
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000060fe0 sp=0x14000060fe0 pc=0x1043e6c94
goroutine 1 [running]:
goroutine running on other thread; stack unavailable
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/proc.go:381 +0xe0 fp=0x1400004efa0 sp=0x1400004ef80 pc=0x1043bcd30
runtime.goparkunlock(...)
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/proc.go:387
runtime.forcegchelper()
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/proc.go:305 +0xb0 fp=0x1400004efd0 sp=0x1400004efa0 pc=0x1043bcb80
runtime.goexit()
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400004efd0 sp=0x1400004efd0 pc=0x1043e6c94
created by runtime.init.6
/opt/homebrew/Cellar/go/1.20.2/libexec/src/runtime/proc.go:293 +0x24
Here is the example file i used to test: S_and_D-Spring_2008.pdf
I cannot reproduce crash with your example file and with the code I pasted above, that same code crashes for you or what? You are mentioning goroutines, you are actually trying to use goroutines for Image()
or not? That is like the one and only open issue and that is not supported. Please, I don't want to pull the info from you anymore, I don't have time for that, send an example that will crash. If you are trying to use goroutines then the issue is invalid, because that is not supported.
I used the code that you sent me above, not modify anything except the path. Can you try to reproduce on apple m1 device?
No, I don't have or use apple devices. If you are having problems with bundled library try with the external library.
thank you for your support, i will close the issue.
Hi, im converting around 30 pages to jpg, size of each image around 500kb to 2mb. Some image was converted successfully but some throw errors
Below is the code, i just following the snippet
I'm using arm64 arch to execute those code