Imagick / imagick

🌈 The Imagick PHP extension 🌈
http://pecl.php.net/imagick
Other
540 stars 136 forks source link

274_imagick_setImageAlpha.phpt test fails #339

Open Whissi opened 4 years ago

Whissi commented 4 years ago

Test 274_imagick_setImageAlpha.phpt fails in imagick-3.4.4 against imagemagick-7.0.10.23.

---- EXPECTED OUTPUT
Ok
---- ACTUAL OUTPUT
Pixel values appear incorrect for pixelType 3:array(4) {
  [0]=>
  float(0.50196081399918)
  [1]=>
  float(0)
  [2]=>
  float(0.50196081399918)
  [3]=>
  float(0.50000762939453)
}
Pixel values appear incorrect for pixelType 2:array(4) {
  [0]=>
  float(0.50196078431373)
  [1]=>
  float(0)
  [2]=>
  float(0.50196078431373)
  [3]=>
  float(0.50000762951095)
}
Ok
---- FAILED

Not sure if this is a flaky test depending on which CPU is used?

Danack commented 4 years ago

depending on which CPU is used?

Shouldn't be. The math should be conformant to the appropriate IEEE spec.

This is more like to be an off by one error in that particular version of ImageMagick. The tests are green against IM7.0.10-27.

So...please test against that.

Whissi commented 4 years ago

Exactly the same failure with 7.0.10-27.

Danack commented 4 years ago

Can you post some details of your CPU + OS + configure flags you use for ImageMagick - or if it's installed from a package.

There's probably nothing I can do, but it would be interesting to know what's going on.

Whissi commented 4 years ago

This is Gentoo Linux, so everything is build from source:

Portage 2.3.103 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-9.3.0, glibc-2.31-r6, 5.8.0-gentoo-r1-x86_64 x86_64)
=================================================================
System uname: Linux-5.8.0-gentoo-r1-x86_64-x86_64-AMD_Ryzen_Threadripper_3970X_32-Core_Processor-with-gentoo-2.6
KiB Mem:    21206492 total,   1791432 free
KiB Swap:    8388604 total,   8377520 free
Timestamp of repository gentoo: Wed, 19 Aug 2020 15:45:01 +0000
Head commit of repository gentoo: 1b2c38a725add6d6d04de60992c53717c72cc7cd
sh bash 5.0_p17
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
ccache version 3.7.10 [enabled]
app-shells/bash:          5.0_p17::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r1::gentoo, 3.7.8-r2::gentoo, 3.8.4-r1::gentoo
dev-util/ccache:          3.7.10::gentoo
dev-util/cmake:           3.16.5::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.18::gentoo
sys-devel/autoconf:       2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo

as well as

Portage 3.0.3 (python 3.7.8-final-0, default/linux/amd64/17.1, gcc-10.2.0, glibc-2.31-r6, 4.9.0-12-amd64 x86_64)
=================================================================
System uname: Linux-4.9.0-12-amd64-x86_64-Intel-R-_Xeon-R-_Silver_4110_CPU_@_2.10GHz-with-gentoo-2.7
KiB Mem:   131661452 total,  88017100 free
KiB Swap:   12582908 total,  12582908 free
Timestamp of repository gentoo: Tue, 18 Aug 2020 22:00:01 +0000
Head commit of repository gentoo: 72f0a4de3ebd9dac4706496bad9ac5fb8668cb35
sh bash 5.0_p18
ld GNU ld (Gentoo 2.34 p4) 2.34.0
ccache version 3.7.11 [enabled]
app-shells/bash:          5.0_p18::gentoo
dev-lang/perl:            5.30.3-r1::gentoo
dev-lang/python:          2.7.18-r1::gentoo, 3.7.8-r2::gentoo, 3.8.5::gentoo
dev-util/ccache:          3.7.11::gentoo
dev-util/cmake:           3.17.2::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2::gentoo
sys-devel/binutils:       2.34-r1::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo, 10.2.0::gentoo
sys-devel/gcc-config:     2.3.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.7::gentoo (virtual/os-headers)
sys-libs/glibc:           2.31-r6::gentoo

IM details:

# convert -list configure

Path: /usr/lib64/ImageMagick-7.0.10//config-Q16/configure.xml

Name                  Value
-------------------------------------------------------------------------------
CC                    x86_64-pc-linux-gnu-gcc
CFLAGS                -I/usr/include/libxml2  -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/uuid -I/usr/include/libpng16  -I/usr/include/librsvg-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gdk-pixbuf-2.0 -pthread -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/uuid -I/usr/include/libpng16  -I/usr/include/libpng16  -I/usr/include/freetype2      -Wall -O2 -pipe -march=znver1 -mtune=znver1 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH            /usr/lib64/ImageMagick-7.0.10/modules-Q16/coders
CONFIGURE             ./configure  '--prefix=/usr' '--build=x86_64-pc-linux-gnu' '--host=x86_64-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--disable-dependency-tracking' '--disable-silent-rules' '--docdir=/usr/share/doc/imagemagick-7.0.10.27' '--htmldir=/usr/share/doc/imagemagick-7.0.10.27/html' '--with-sysroot=/' '--libdir=/usr/lib64' '--disable-static' '--disable-hdri' '--disable-opencl' '--with-threads' '--with-modules' '--with-quantum-depth=16' '--with-magick-plus-plus' '--without-perl' '--with-perl-options=INSTALLDIRS=vendor' '--with-gs-font-dir=/usr/share/fonts/urw-fonts' '--with-bzlib' '--without-x' '--with-zlib' '--without-autotrace' '--without-dps' '--without-djvu' '--with-dejavu-font-dir=/usr/share/fonts/dejavu' '--without-fftw' '--without-fpx' '--without-fontconfig' '--with-freetype' '--without-gslib' '--without-gvc' '--without-heic' '--without-jbig' '--with-jpeg' '--without-openjp2' '--without-jxl' '--without-lcms' '--without-lqr' '--without-lzma' '--without-openexr' '--without-pango' '--with-png' '--without-raw' '--with-rsvg' '--without-tiff' '--without-webp' '--without-windows-font-dir' '--without-wmf' '--with-xml' '--disable-openmp' '--with-gcc-arch=no-automagic' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=x86_64-pc-linux-gnu' 'CFLAGS=-O2 -pipe -march=znver1 -mtune=znver1' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed' 'CXXFLAGS=-O2 -pipe -march=znver1 -mtune=znver1'
CONFIGURE_PATH        /etc/ImageMagick-7/
COPYRIGHT             Copyright (C) 1999-2020 ImageMagick Studio LLC
CPPFLAGS              -I/usr/include/ImageMagick-7
CXX                   x86_64-pc-linux-gnu-g++
CXXFLAGS              -O2 -pipe -march=znver1 -mtune=znver1 -pthread
DEFS                  -DHAVE_CONFIG_H
DELEGATES             bzlib mpeg freetype jng jpeg png rsvg xml zlib zstd
DISTCHECK_CONFIG_FLAGS 'CFLAGS=-O2 -pipe -march=znver1 -mtune=znver1' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed'  --disable-deprecated  --with-quantum-depth=16  --with-jemalloc=no  --with-umem=no  --with-autotrace=no  --with-dps=no  --with-dejavu-font-dir=/usr/share/fonts/dejavu  --with-fftw=no  --with-fpx=no  --with-djvu=no  --with-fontconfig=no  --with-gslib=no  --with-fontpath=  --with-gs-font-dir=/usr/share/fonts/urw-fonts  --with-gvc=no  --with-heic=no  --with-jxl=no  --with-lcms=no  --with-openjp2=no  --with-lqr=no  --with-lzma=no  --with-openexr=no  --with-pango=no  --with-libraw=no  --with-tiff=no  --with-webp=no  --with-windows-font-dir=no  --with-wmf=no  --with-perl=no
DOCUMENTATION_PATH    /usr/share/doc/ImageMagick-7
EXEC-PREFIX           /usr
EXECUTABLE_PATH       /usr/bin
FEATURES              DPC Cipher Modules
FILTER_PATH           /usr/lib64/ImageMagick-7.0.10/modules-Q16/filters
GIT_REVISION          17526
HOST                  x86_64-pc-linux-gnu
INCLUDE_PATH          /usr/include/ImageMagick-7
LDFLAGS               -L/usr/lib64 -Wl,-O1 -Wl,--as-needed
LIB_VERSION           0x70A
LIB_VERSION_NUMBER    7,0,10,27
LIBRARY_PATH          /usr/lib64/ImageMagick-7.0.10
LIBS                    -lfreetype     -lxml2         -lbz2 -lz    -lltdl   -lm    -lpthread
NAME                  ImageMagick
PCFLAGS               -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX                /usr
QuantumDepth          16
RELEASE_DATE          2020-08-19
SHARE_PATH            /usr/share/ImageMagick-7
SHAREARCH_PATH        /usr/lib64/ImageMagick-7.0.10/config-Q16
TARGET_CPU            x86_64
TARGET_OS             linux-gnu
TARGET_VENDOR         pc
VERSION               7.0.10
WEBSITE               https://imagemagick.org

Path: [built-in]

Name                  Value
-------------------------------------------------------------------------------
DELEGATES             bzlib cairo freetype jng jpeg ltdl png rsvg xml zlib
FEATURES              Cipher DPC Modules
MAGICK_TEMPORARY_PATH /tmp
NAME                  ImageMagick
QuantumDepth          Q16
Danack commented 4 years ago

This is more like to be an off by one error i

Ignore that...I confused this test with a different one. This one shouldn't fail for off by one errors.

I've improved the test to actually give useful info when it fails, rather than only showing useless info.

Also, if you have a docker file for gentoo, similar to the one I use for developing, please open a PR with just that, as it would make life easier for me in future.

Whissi commented 4 years ago

I haven't forgotten about this. Just need to find time to understand what's the best way to provide you with a Gentoo docker file.

Whissi commented 3 years ago

I found the trigger: When you build imagemagick with --enable-hdri=yes, test will pass. But with --disable-hdri you hit the problem. I am wondering if you can detect that in test suite and skip test in case hdri is missing.

Danack commented 3 years ago

I am wondering if you can detect that in test suite and skip test in case hdri is missing.

No.

There exists in such a case a certain institution or law; let us say, for the sake of simplicity, a fence or gate erected across a road. The more modern type of reformer goes gaily up to it and says, “I don’t see the use of this; let us clear it away.” To which the more intelligent type of reformer will do well to answer: “If you don’t see the use of it, I certainly won’t let you clear it away. Go away and think. Then, when you can come back and tell me that you do see the use of it, I may allow you to destroy it.”

That test is testing that there isn't an off-by one error in the code, where the value 2**16 has been used instead of (2**16) -1). I think the maths should work out the same regardless of whether hdri is used or not.

I'll give that a test on debian....at some point. If it fails there then I'll investigate why. If it doesn't it can be reported as an upstream bug.

Whissi commented 3 years ago

Thank you for the explanation.

To add another data point: When using imagemagick-6 to tun test suite, it doesn't matter if you run with hdri enabled or not. Just imagemagick-7 will return different values.