On 01/23/2015 03:53 PM, Eric Blake wrote: > On 01/23/2015 02:58 PM, Eric Blake wrote: >> http://pubs.opengroup.org/onlinepubs/9699919799/functions/setjmp.html is >> clear: >> >> "It is unspecified whether setjmp() is a macro or a function. If a macro >> definition is suppressed in order to access an actual function, or a >> program defines an external identifier with the name setjmp, the >> behavior is undefined." >> >> But in readline's posixjmp.h wrapper file, you do: >> >> #if defined (HAVE_POSIX_SIGSETJMP) >> # define procenv_t sigjmp_buf >> # if !defined (__OPENNT) >> # undef setjmp >> # define setjmp(x) sigsetjmp((x), 1) > > You also define a setjmp_nosigs, but nothing in the readline sources > uses it. For that matter, readline only has two instances of setjmp > clients, both which will never be reached when HAVE_POSIX_SIGSETJMP is > defined. > > And why are you passing 0 to sigsetjmp in those two clients? Don't you > generally want to preserve signal masks by passing a nonzero value, > rather than leave it unspecified whether they are preserved?
Okay, I see that while readline doesn't use setjmp_nosigs, the rest of bash source does. Remember, POSIX states that sigsetjmp(x, 0) is the same as setjmp(x), which may or may not save the signal mask; on Cygwin, the signal mask is ALWAYS saved (that is, the second argument of sigsetjmp() makes no difference in behavior; there is never a way to explicitly opt out of saving signals). Thus, the following is the minimal patch for Cygwin to have correct compilation (both setjmp and setjmp_nosigs usage points in bash will have identical behavior). Although I still think that you ought to fix more than just Cygwin by auditing and eradicating all uses of setjmp in favor of sigsetjmp to begin with, that's a bigger patch to bash, so I'm not going to bother with doing it myself now that I have a correct environment on cygwin. diff --git i/lib/readline/posixjmp.h w/lib/readline/posixjmp.h index 98cf718..1af5de7 100644 --- i/lib/readline/posixjmp.h +++ w/lib/readline/posixjmp.h @@ -1,6 +1,6 @@ /* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */ -/* Copyright (C) 1987,1991 Free Software Foundation, Inc. +/* Copyright (C) 1987,1991,2015 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -27,7 +27,7 @@ #if defined (HAVE_POSIX_SIGSETJMP) # define procenv_t sigjmp_buf -# if !defined (__OPENNT) +# if !defined (__OPENNT) && !defined (__CYGWIN__) # undef setjmp # define setjmp(x) sigsetjmp((x), 1) # define setjmp_nosigs(x) sigsetjmp((x), 0) -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature