Opened 7 years ago

Closed 7 years ago

#7023 closed defect (invalid)

Internal png version (1.2.56) contains a logical error

Reported by: mj10777 Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: svn-trunk
Severity: major Keywords: logical error internal PNG version
Cc:

Description

While working on a QgsRasterLite2Provider, I noticed a problem that was caused by a gdal version compiled with --with-png=internal.

It seems that QgsRasterDataProvider is dependent on gdal, so it is also loaded when running.

Since QgsRasterLite2Provider calls librasterlite2, which is compiled with another libpng, the following error occurs:

libpng warning: [gdal, read] Application was compiled with png.h from libpng-1.6.10

libpng warning: [gdal, read] Application is running with png.c from libpng-1.2.56

libpng error: [gdal, read] Incompatible libpng version in application and library

(I added the '[gdal, read]' to make sure where this was coming from, since I don't have a libpng1.2.56 installed)


In pngread.c and pngwrite.c there is an inline comment explaining this error:

Libpng 0.90 and later are binary incompatible with libpng 0.89, so we must recompile any applications that use any older library For versions after libpng 1.0, we will be compatible, so we need only check the first digit.

This implies that that this error should only occur when running with a version < 0.9, but due to a faulty 'if' effects all 1.* versions with the exception 1.2.*.

Replacing :

      if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
          (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
          (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
      {

with

     if (user_png_ver == NULL || (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
     {

in both files resolves this problem.

This check was used until the last 1.4 version of libpng.

Change History (2)

comment:1 by Even Rouault, 7 years ago

It isn't sane at all to use a GDAL with internal libpng and a librasterlite2 compiled with another libpng. In that situation you should build both against an external libpng, which is the same. I doubt hacking the source of the GDAL internal libpng is the right solution.

comment:2 by Even Rouault, 7 years ago

Resolution: invalid
Status: newclosed

Closing. I don't think there's anything wrong on GDAL side. This is a build issue. Mixing different libpng versions will result in symbol clashing and all sort of issues.

Note: See TracTickets for help on using tickets.