Kagami / go-avif

:art: Go AVIF library
Creative Commons Zero v1.0 Universal
325 stars 20 forks source link

avif conversion utility segfaults #1

Open MartiCode opened 5 years ago

MartiCode commented 5 years ago

Using command: avif -s 5 -q 25 -e IMG_3890.JPG -o delme.avif

Gives: fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7f28b05b14f4]

runtime stack: runtime.throw(0x533bec, 0x2a) /usr/lib/go-1.10/src/runtime/panic.go:616 +0x81 runtime.sigpanic() /usr/lib/go-1.10/src/runtime/signal_unix.go:372 +0x28e

goroutine 1 [syscall]: runtime.cgocall(0x4e6ba0, 0xc420041d48, 0x4f7020) /usr/lib/go-1.10/src/runtime/cgocall.go:128 +0x64 fp=0xc420041d18 sp=0xc420041ce0 pc=0x403004 github.com/Kagami/go-avif._Cfunc_avif_encode_frame(0xc421524f80, 0xc420046000, 0xc420046310, 0x0) _cgo_gotypes.go:115 +0x4d fp=0xc420041d48 sp=0xc420041d18 pc=0x4b5e1d github.com/Kagami/go-avif.Encode.func3(0xc421524f80, 0xc420046000, 0xc420046310, 0x5453c0) /home/pierre/go/src/github.com/Kagami/go-avif/avif.go:186 +0x12d fp=0xc420041d80 sp=0xc420041d48 pc=0x4b6dad github.com/Kagami/go-avif.Encode(0x545140, 0xc42000e3e8, 0x545b40, 0xc42005a080, 0xc420041e98, 0x0, 0x0) /home/pierre/go/src/github.com/Kagami/go-avif/avif.go:186 +0x5ab fp=0xc420041ec8 sp=0xc420041d80 pc=0x4b682b main.main() /home/pierre/go/src/github.com/Kagami/go-avif/cmd/avif/main.go:102 +0x2ac fp=0xc420041f88 sp=0xc420041ec8 pc=0x4e67ec runtime.main() /usr/lib/go-1.10/src/runtime/proc.go:198 +0x212 fp=0xc420041fe0 sp=0xc420041f88 pc=0x42a832 runtime.goexit() /usr/lib/go-1.10/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420041fe8 sp=0xc420041fe0 pc=0x451be1

Kagami commented 5 years ago

Thank you for the report.

Is it happening on any image or only this particular? What libaom version do you use?

MartiCode commented 5 years ago

Seems to happen with every JPEG I tried. The version of libaom-dev as reported by apt:

Version: 1.0.0-3\~18.04.york0 Depends: libaom0 (= 1.0.0-3\~18.04.york0)

Kagami commented 5 years ago

I've installed the same libaom in Ubuntu 18.04 in Docker container and can't reproduce that issue. It might be related to your system.

Try with latest libaom from git. See instructions here.

radum commented 5 years ago

I have the same issue and I installed it to WSL on Windows 10.

@Kagami can you paste your docker file?

Kagami commented 5 years ago
FROM ubuntu:18.04

RUN apt-get update \
  && apt-get install -y software-properties-common git golang \
  && add-apt-repository -y ppa:jonathonf/ffmpeg-4 \
  && apt-get update \
  && apt-get install -y libaom-dev \
  && mkdir -p /go/src/github.com/Kagami \
  && cd /go/src/github.com/Kagami \
  && git clone https://github.com/Kagami/go-avif.git \
  && GOPATH=/go go get -v ./...

ENTRYPOINT ["/go/bin/avif"]
docker build -t avif .
docker run --rm -v `pwd`:/mnt avif -e /mnt/tiger.jpg -o /mnt/tiger.avif

This works fine for me.

MartiCode commented 5 years ago

It seems to work with smallish images and not with larger ones. Could it be an issue with running out of memory? I have tried to manually convert to AVIF using ffmpeg/libaom/mp4box and on larger pictures (ie 4000x5000) the process quickly balloons and runs out of memory (on a 32Gb system). If so some check and proper "out of memory" error reporting would be useful.

Kagami commented 5 years ago

Thanks, I finally can reproduce issue!

On 5412x7216 image with libaom 1.0.0 I get segfault and with latest libaom from git it's:

$ aomenc -o big.ivf big.y4m
Failed to initialize encoder: Memory allocation error

I will report that to aomedia.

Orum commented 5 years ago

Any update on this? Is libaom still bugged? If so, I don't suppose you're willing to support another encoder in the meantime...