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? As for avoiding the undefined behavior, I think the patch is as simple as: diff --git i/lib/readline/callback.c w/lib/readline/callback.c index 6bb2c3e..56f43e7 100644 --- i/lib/readline/callback.c +++ w/lib/readline/callback.c @@ -1,6 +1,6 @@ /* callback.c -- functions to use readline as an X `callback' mechanism. */ -/* Copyright (C) 1987-2009 Free Software Foundation, Inc. +/* Copyright (C) 1987-2009, 2015 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -125,11 +125,7 @@ rl_callback_read_char () } memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t)); -#if defined (HAVE_POSIX_SIGSETJMP) jcode = sigsetjmp (_rl_top_level, 0); -#else - jcode = setjmp (_rl_top_level); -#endif if (jcode) { (*rl_redisplay_function) (); diff --git i/lib/readline/posixjmp.h w/lib/readline/posixjmp.h index 98cf718..356828e 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,16 +27,11 @@ #if defined (HAVE_POSIX_SIGSETJMP) # define procenv_t sigjmp_buf -# if !defined (__OPENNT) -# undef setjmp -# define setjmp(x) sigsetjmp((x), 1) -# define setjmp_nosigs(x) sigsetjmp((x), 0) -# undef longjmp -# define longjmp(x, n) siglongjmp((x), (n)) -# endif /* !__OPENNT */ #else # define procenv_t jmp_buf -# define setjmp_nosigs setjmp +# ifndef sigsetjmp +# define sigsetjmp(x, ignored) setjmp (x) +# endif #endif #endif /* _POSIXJMP_H_ */ diff --git i/lib/readline/readline.c w/lib/readline/readline.c index abb29a0..f9ac97c 100644 --- i/lib/readline/readline.c +++ w/lib/readline/readline.c @@ -1,7 +1,7 @@ /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ -/* Copyright (C) 1987-2013 Free Software Foundation, Inc. +/* Copyright (C) 1987-2013, 2015 Free Software Foundation, Inc. This file is part of the GNU Readline Library (Readline), a library for reading lines of text with interactive input and history editing. @@ -534,11 +534,7 @@ readline_internal_charloop () #endif lk = _rl_last_command_was_kill; -#if defined (HAVE_POSIX_SIGSETJMP) code = sigsetjmp (_rl_top_level, 0); -#else - code = setjmp (_rl_top_level); -#endif if (code) { -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature