bakape / thumbnailer

Go media thumbnailer
MIT License
152 stars 36 forks source link

fatal error: unexpected signal during runtime execution #57

Closed paulm17 closed 4 years ago

paulm17 commented 4 years ago

Trying to run this neat library, but keeps on crashing for me.

I tried with the ffmpeg mentioned in the readme but still the same.

My code:

opts := thumbnailer.Options{
    ThumbDims: thumbnailer.Dims{250, 250},
}

_, thumbImg, err := thumbnailer.Process(f, opts)
if err != nil {
    return nil, err
}

// name of output file, also determines output type
dir := common.GetDir() + "/upload/dam/"
outFilename := fmt.Sprintf("%s%d_%s.%s", dir, size, m["fileID"], "png")

// Save File
if err != thumbnailer.ErrCantThumbnail {
    f, err := os.Create(outFilename)
    if err != nil {
        return nil, err
    }
    defer f.Close()

    err = png.Encode(f, thumbImg)
    if err != nil {
        return nil, err
    }
}

Panic:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0xcffe97]

runtime stack:
runtime.throw(0x150fdeb, 0x2a)
    /usr/lib/go-1.12/src/runtime/panic.go:617 +0x72
runtime.sigpanic()
    /usr/lib/go-1.12/src/runtime/signal_unix.go:374 +0x4a9

goroutine 45 [syscall]:
runtime.cgocall(0x957430, 0xc0001329b8, 0xc000198d80)
    /usr/lib/go-1.12/src/runtime/cgocall.go:128 +0x5b fp=0xc000132988 sp=0xc000132950 pc=0x4a439b
github.com/bakape/thumbnailer._Cfunc_retrieve_meta(0x7f68500022e0, 0x0, 0x0)
    _cgo_gotypes.go:1222 +0x49 fp=0xc0001329b8 sp=0xc000132988 pc=0x82a7c9
github.com/bakape/thumbnailer.(*FFContext).Meta.func1(0xc00000e940, 0xc0001a83c0, 0x7f68500022e0)
    /srv/www/app.platformdev.com/public_html/golang/src/github.com/bakape/thumbnailer/meta.go:8 +0x5e fp=0xc0001329f8 sp=0xc0001329b8 pc=0x82d27e
github.com/bakape/thumbnailer.(*FFContext).Meta(0xc00000e940, 0x0, 0x0, 0x0, 0x0)
    /srv/www/app.platformdev.com/public_html/golang/src/github.com/bakape/thumbnailer/meta.go:8 +0x49 fp=0xc000132a28 sp=0xc0001329f8 pc=0x82c049
github.com/bakape/thumbnailer.processMedia(0x15b3b00, 0xc0000100c8, 0xc0000648a0, 0x0, 0x0, 0xfa, 0xfa, 0x0, 0x0, 0x0, ...)
    /srv/www/app.platformdev.com/public_html/golang/src/github.com/bakape/thumbnailer/thumbnailer.go:64 +0x110 fp=0xc000132aa0 sp=0xc000132a28 pc=0x82c4c0
github.com/bakape/thumbnailer.Process(0x15b3b00, 0xc0000100c8, 0x0, 0x0, 0xfa, 0xfa, 0x0, 0x5100de, 0xc000132bb0, 0x4cc311, ...)
bakape commented 4 years ago

Can you upload the file causing this?

paulm17 commented 4 years ago

Thanks for the quick response. Here is the link: https://www.dropbox.com/s/wt8m4z7nr0lsjp0/big_buck_bunny_720p_1mb.mp4?dl=0

Let me know if you have issues and I'll share it elsewhere.

bakape commented 4 years ago

I'm on Ubuntu 19.04 and it seems to be working fine. The one thing that might segfault there is null pointer deref on AVFormatContext.meta. Does this fix the problem?

paulm17 commented 4 years ago

Unfortunately it does not. I will upgrade to 19.04 and then report back.

paulm17 commented 4 years ago

I've upgraded to 19.10 and still have the same issue.

What's your version of ffmpeg? thanks

bakape commented 4 years ago
ffmpeg version 4.1.3-0ubuntu1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.3.0-6ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

This is stock ubuntu FFmpeg and not compiled from sources, as it seems the ubuntu patch bugs no longer affect them.

paulm17 commented 4 years ago

I upgraded from the manual compile I had under 18.10 to the newer 4.1.3 with 19.04.

I also mocked up a standalone program with the above code and it works fine. Although my main program still does not. But I'm sure it's a fault on my end somewhere.

Seeing as it works standalone, I'm closing this.

Many thanks for your help and building out this library also.

paulm17 commented 4 years ago

This morning, I finally got to the bottom of this.

I'm using https://github.com/discordapp/lilliput for fast image resizing. If I use lilliput and thumbnailer together in the same app, then I get the crash.

goroutine 1 [syscall]:
runtime.cgocall(0x5bd270, 0xc000049bb8, 0x5a3cee)
    /usr/lib/go-1.13/src/runtime/cgocall.go:128 +0x5b fp=0xc000049b88 sp=0xc000049b50 pc=0x4a315b

I presume that because are both using cgo at the same time?

It's all good now. I'm running an MQ and have put videos and other types of files into separate executables.

bakape commented 4 years ago

The problem seems to be that lilliput https://github.com/discordapp/lilliput statically links to precompiled static FFmpeg library archives but thumbnailer links against system FFmpeg libraries, resulting in a link conflict. These libraries can not be used together in the same Go binary.

On Sun, 22 Sep 2019 at 11:41, Paul notifications@github.com wrote:

This morning, I finally got to the bottom of this.

I'm using https://github.com/discordapp/lilliput for fast image resizing. If I use lilliput and bakape together in the same app, then I get the crash.

goroutine 1 [syscall]: runtime.cgocall(0x5bd270, 0xc000049bb8, 0x5a3cee) /usr/lib/go-1.13/src/runtime/cgocall.go:128 +0x5b fp=0xc000049b88 sp=0xc000049b50 pc=0x4a315b

I presume that because are both using cgo at the same time?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bakape/thumbnailer/issues/57?email_source=notifications&email_token=AB347MHUZQXQLYHQUJI77KLQK4VUZA5CNFSM4IY6UZI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7JBKWY#issuecomment-533861723, or mute the thread https://github.com/notifications/unsubscribe-auth/AB347ME5B5ZLZTBQJ57Q6E3QK4VUZANCNFSM4IY6UZIQ .

paulm17 commented 4 years ago

Thanks for the confirmation!