Bug 494579

Summary: Attempt to centralize setjmp.h leads to confusing results
Product: [Fedora] Fedora Reporter: Jeroen van Meeuwen <vanmeeuwen+fedora>
Component: libpngAssignee: Tom Lane <tgl>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: high    
Version: 10CC: hhorak, tgl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-12-18 09:12:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jeroen van Meeuwen 2009-04-07 14:24:06 UTC
Description of problem:

Compiling an application with PNG support leads to the inclusion of /usr/include/libpng12/pngconf.h.

In this file, the following snippet occurs:

==
#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
#  define PNG_SETJMP_SUPPORTED
#endif

#ifdef PNG_SETJMP_SUPPORTED
/* This is an attempt to force a single setjmp behaviour on Linux.  If
 * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
 */

#  ifdef __linux__
#    ifdef _BSD_SOURCE
#      define PNG_SAVE_BSD_SOURCE
#      undef _BSD_SOURCE
#    endif
#    ifdef _SETJMP_H
     /* If you encounter a compiler error here, see the explanation
      * near the end of INSTALL.
      */
         __pngconf.h__ already includes setjmp.h;
         __dont__ include it again.;
#    endif
#  endif /* __linux__ */

   /* include setjmp.h for error handling */
#  include <setjmp.h>

#  ifdef __linux__
#    ifdef PNG_SAVE_BSD_SOURCE
#      ifndef _BSD_SOURCE
#        define _BSD_SOURCE
#      endif
#      undef PNG_SAVE_BSD_SOURCE
#    endif
#  endif /* __linux__ */
#endif /* PNG_SETJMP_SUPPORTED */
==

This application I'm building (LGPLv3) includes many different header files from many different locations, including /usr/include/setjmp.h and /usr/include/bits/setjmp.h (glibc-headers). Other packages include setjmp.h as well, and.

It is wrong for the above snippet to check for _SETJMP_H being defined or not, as it is set by glibc-header's setjmp.h. I could not find a way to define PNG_NOT_SETJMP_SUPPORTED or PNG_SETJMP_NOT_SUPPORTED from within the external application I wanted to compile. If there is a way, please let me know ;-)

Maybe, libpng12/pngconf.h should use _LIBPNG_SETJMP_H such as /usr/include/bits/setjmp.h does in glibc-headers (using _BITS_SETJMP_H)

Version-Release number of selected component (if applicable):

libpng-1.2.35-1.fc10.i386

Comment 1 Tom Lane 2009-04-08 00:11:54 UTC
Actually, that code is very intentionally trying to check whether you already included setjmp.h; the consequences of not doing this appear worse than those of doing it.  I'd suggest doing what the comment tells you to, ie make sure you include png.h ahead of setjmp.h.

I've asked upstream whether they can't make this a little less painful in the next major release, but it will probably not be changing in the 1.2.x series because it'd break existing applications.  The fundamental problem is that linux contains two incompatible versions of setjmp/longjmp, and if you use one while libpng is using the other, your code *will* fail.

You might be able to reduce your pain by including png.h only in one or a few modules (that also contain whatever code tries to catch longjmps out of libpng).

Comment 2 Jeroen van Meeuwen 2009-04-08 13:33:54 UTC
The code does include png.h which in turn includes setjmp.h. Fwiw, the software I'm attempting to compile is:

http://www.ecmwf.int/products/data/software/magics++.html

Download link: http://www.ecmwf.int/products/data/software/download/software_files/Magics++-2.6.4.tar.gz

The code including png.h is at:

Magics++-2.6.4/src/drivers/OpenGL/OpenGLBaseWidget.cc:45:#include <png.h>
Magics++-2.6.4/src/drivers/OpenGL/OpenGLLabelWidget.cc:45:#include <png.h>
Magics++-2.6.4/src/drivers/OpenGL/OpenGLTextureItem.cc:41:#include <png.h>

Not including setjmp.h here:

[jmeeuwen@ghandalf OpenGL]$ grep -rin setjmp.h *
[jmeeuwen@ghandalf OpenGL]$ pwd
/home/jmeeuwen/rpmbuild/SOURCES/Magics++-2.6.4/src/drivers/OpenGL

Or anyone else for that matter:

[jmeeuwen@ghandalf Magics++-2.6.4]$ grep -rin setjmp.h *
[jmeeuwen@ghandalf Magics++-2.6.4]$ pwd
/home/jmeeuwen/rpmbuild/SOURCES/Magics++-2.6.4

Comment 3 Bug Zapper 2009-11-18 07:50:16 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Bug Zapper 2009-12-18 09:12:51 UTC
Fedora 10 changed to end-of-life (EOL) status on 2009-12-17. Fedora 10 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.