[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libpng evil setjmp 'fixes'

Le vendredi 18 février 2005 à 12:12 +1030, Ron a écrit : 
> Hi,
> Are you aware of this:
> /usr/include/pngconf.h:310:2: #error png.h already includes setjmp.h
>                                      with some additional fixup.
> It occurs if you (or any other header you include) #include <setjmp.h>
> before png.h -- so the potential for conflict with other users of
> setjmp is very high.
> Is there anything we can do about this?  The sjlj error handling is
> nice, but what is needed here that (for eg.) libjpeg does not need to
> get much the same effect.  My first impression is that this should be
> fixed before the stable release, as I can't see what extenuating
> circumstances might justify it, but I'm always open to the idea they
> might exist...

This is to force the system not to use the BSD-compatibility setjmp.
According to the sources, the X includes set _BSD_SOURCE, and doing this
bring a different behaviour for setjmp.

1) I cannot find any reference to _BSD_SOURCE or such stuff in the X
includes, at least for XFree. That would be a bug, as _BSD_SOURCE should
be defined by the user, not the includes.
2) The fix is dependent on glibc features, and with glibc 2.3, it is
moot. The features.h header is included before the _BSD_SOURCE stuff,
through sys/types.h. Thus, if _BSD_SOURCE is set, it will define
__FAVOR_BSD, and setjmp.h will still use the BSD version. I have just
tested that building libpng with -D_BSD_SOURCE actually makes use of the
BSD version of setjmp.
3) I don't really understand what can break when using the BSD version
of setjmp. Is it when an application uses the BSD semantics while the
library uses the Linux semantics? Are there really cases where it
matters, especially when the difference is so small? It should only
matter if the application uses longjmp on a context saved by libpng
*and* the signal mask was changed meanwhile.

If no one opposes, I can remove it from the Debian package, letting a
warning when _BSD_SOURCE is defined, but I'd like to be sure that
nothing will break, so I'd like some more opinions. Cc-ing the lists,
maybe someone will have more clues.

 .''`.           Josselin Mouette        /\./\
: :' :           josselin.mouette@ens-lyon.org
`. `'                        joss@debian.org
   `-  Debian GNU/Linux -- The power of freedom

Reply to: