mozilla / mozjpeg

Improved JPEG encoder.
Other
5.47k stars 415 forks source link

Segmentation fault: 11 on macOS Sierra #237

Open adrianorsouza opened 7 years ago

adrianorsouza commented 7 years ago

Hi guys,

I'm getting the Segmentation fault:11 error after compile and install mozjpeg on macOS 10.12.2 and trying to compress large images (something like ~500KB).

The mozjpeg runs fine and compress only small images lower than ~200KB for large images the error is shown and the output image is saved with 0 bytes.

automake --version
automake (GNU automake) 1.15
nasm -version
NASM version 2.12.02 compiled on Jan 18 2017
cjpeg -version
mozjpeg version 3.1 (build 20170118)

TO REPRODUCE THE ERROR

curl -OL https://github.com/mozilla/mozjpeg/releases/download/v3.1/mozjpeg-3.1-release-source.tar.gz

tar -xzvf mozjpeg-3.1-release-source.tar.gz
cd mozjpeg

./configure --prefix=/usr/local/mozjpeg

make && make install
cjpeg -quality 70 -outfile compressed-image.jpg hawaii-orig.jpg  
Segmentation fault: 11

I've found in this comment: https://github.com/mozilla/mozjpeg/issues/202#issuecomment-213376751 that by using the flag --without-simd would avoid crashes, by doing so it did solve my the problem, but anyhow I decide to report this issue.

NOTE: with this test I used images borrowed from https://kornel.ski/dssim which: This https://kornel.ski/dssim/hawaii-orig.jpg LARGE DOESNOT WORK This https://kornel.ski/dssim/hawaii-q70.jpg SMALL WORKS

kornelski commented 7 years ago

Can you reproduce it on master? (you'll need to add autoreconf -ifv before configure)

adrianorsouza commented 7 years ago

@pornel Sorry but I couldn't reproduce it on master because running autoreconf -ifv throws the following error:

$ autoreconf -ifv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force 
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/local/autoconf-2.69/bin/autoconf --force
configure.ac:23: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/local/autoconf-2.69/bin/autoconf failed with exit status: 1
kornelski commented 7 years ago

You need to install libtool

adrianorsouza commented 7 years ago

That might be something wrong with my system which I couldn't figure out

I had libtool shipped with XCode:

$ which libtool
/usr/bin/libtool

$ libtool -V
Apple Inc. version cctools-895

Then I did install the latest version of libtool:

$ which libtool
/usr/local/libtool/bin/libtool

$ libtool --version
libtool (GNU libtool) 2.4.6
Written by Gordon Matzigkeit, 1996

The same error with autoreconf persists.

$ autoconf -V
autoconf (GNU Autoconf) 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
kornelski commented 7 years ago

Sorry, I don't know what's happening. I have the same versions and autoreconf -ivf works for me.

gbiryukov commented 7 years ago

Workarond that helps me (mac os 10.12.5): 1) download binary from here https://github.com/imagemin/mozjpeg-bin/tree/master/vendor/macos 2) upgrade libpng

$ brew upgrade libpng

I have upgraded from 1.6.10 to 1.6.29

And that's it.

If you upgrade libpng first and then will try to rebuild binary from sources maybe it will helps too.