Failure to retrieve image resolution of PNGs with 'Units: Undefined' (clang from Xcode 4.6.3)

Bug #1545319 reported by su_v on 2016-02-13
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

The attached patch allows to work around failure in Inkscape 0.91 and trunk to import certain kinds of PNG images / paste from clipboard correctly with image resolution take from file (default import setting). So far only known to affect builds on OS X 10.7.5 after upgrading Xcode from 4.3.2 to 4.6.3.

Known trigger:
Affected PNG images have 'Units: Undefined' in the output of ImageMagick's identify -verbose command.

Known limitation of patch:
The current patch is only in effect with more recent versions of libpng which support PNG_INCH_CONVERSIONS (png_get_x_pixels_per_inch(), png_get_y_pixels_per_inch()).

Possibly cause:
Underlying issue is possibly a compiler bug (?) with clang from Xcode 4.6.3, triggered e.g. with -02, -O1, but apparently not with debug build -O0 -g. Might be related to libpng's typedef png_uint_32 (likely specific to OS/platform).

Affected compiler (Xcode 4.6.3, OS X 10.7.5):
$ clang --version
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Observed symptoms:
With unpatched code (0.91, 0.91+devel):
* incorrect res_x (--> computed width is incorrect)
* erroneous (huge) res_y (--> computed height is close to zero)
* incorrect unit_type (1 (same as PNG_RESOLUTION_METER) despite unspecified units)

The attached patch also includes debug messages for image resolutions of other image formats (helpful for debugging, but not essential for the workaround with clang from Xcode 4.6.3).
It is unknown to me whether newer versions of clang on later version of OS X or any clang version on other platforms are also affected.

Consistently reproduced, most recent with Inkscape 0.91+devel r14648 (Feb 12 2016), libpng 1.6.20.

See also initial draft for report from Aug 18, 2015:

su_v (suv-lp) wrote :

Test case (from gist)

su_v (suv-lp) wrote :

Patch (used successfully with local builds).

jazzynico (jazzynico) wrote :

Could anyone using Clang on other operating systems test the patch? Thanks!

Changed in inkscape:
milestone: none → 0.92
status: New → In Progress
jazzynico (jazzynico) on 2016-04-06
Changed in inkscape:
assignee: nobody → jazzynico (jazzynico)
jazzynico (jazzynico) wrote :

Tested on Xubuntu 15.10 (libpng-1.2.51) and Windows 7. No regression found with systems that are not affected by the bug.

Patch applied to the trunk rev. 14772 (with new debug function).

Changed in inkscape:
assignee: jazzynico (jazzynico) → su_v (suv-lp)
importance: Undecided → Medium
status: In Progress → Fix Committed
Bryce Harrington (bryce) on 2017-01-10
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers