Patch 8.2.5141
Problem:    Using "volatile int" in a signal handler might be wrong.
Solution:   Use "volatile sig_atomic_t".
Files:      src/os_unix.c, src/proto/os_unix.pro, src/os_win32.c,
            src/proto/os_win32.pro, src/regexp.c,


*** ../vim-8.2.5140/src/os_unix.c       2022-06-20 11:22:58.387360464 +0100
--- src/os_unix.c       2022-06-20 13:26:28.328756274 +0100
***************
*** 8251,8259 ****
  /*
   * Implement timeout with timer_create() and timer_settime().
   */
! static volatile int timeout_flag = FALSE;
! static timer_t        timer_id;
! static int    timer_created = FALSE;
  
  /*
   * Callback for when the timer expires.
--- 8251,8259 ----
  /*
   * Implement timeout with timer_create() and timer_settime().
   */
! static volatile sig_atomic_t timeout_flag = FALSE;
! static timer_t                     timer_id;
! static int                 timer_created = FALSE;
  
  /*
   * Callback for when the timer expires.
***************
*** 8296,8302 ****
   * This function is not expected to fail, but if it does it will still return 
a
   * valid flag pointer; the flag will remain stuck as FALSE .
   */
!     volatile int *
  start_timeout(long msec)
  {
      struct itimerspec interval = {
--- 8296,8302 ----
   * This function is not expected to fail, but if it does it will still return 
a
   * valid flag pointer; the flag will remain stuck as FALSE .
   */
!     volatile sig_atomic_t *
  start_timeout(long msec)
  {
      struct itimerspec interval = {
***************
*** 8347,8363 ****
      }
  }
  
! # else
  
  /*
   * Implement timeout with setitimer()
   */
! static struct itimerval prev_interval;
! static struct sigaction prev_sigaction;
! static volatile int   timeout_flag         = FALSE;
! static int            timer_active         = FALSE;
! static int            timer_handler_active = FALSE;
! static int            alarm_pending        = FALSE;
  
  /*
   * Handle SIGALRM for a timeout.
--- 8347,8362 ----
      }
  }
  
! # else // HAVE_TIMER_CREATE
  
  /*
   * Implement timeout with setitimer()
   */
! static struct sigaction               prev_sigaction;
! static volatile sig_atomic_t  timeout_flag         = FALSE;
! static int                    timer_active         = FALSE;
! static int                    timer_handler_active = FALSE;
! static volatile sig_atomic_t  alarm_pending        = FALSE;
  
  /*
   * Handle SIGALRM for a timeout.
***************
*** 8383,8389 ****
      if (timer_active)
      {
        timer_active = FALSE;
!       ret = setitimer(ITIMER_REAL, &disarm, &prev_interval);
        if (ret < 0)
            // Should only get here as a result of coding errors.
            semsg(_(e_could_not_clear_timeout_str), strerror(errno));
--- 8382,8388 ----
      if (timer_active)
      {
        timer_active = FALSE;
!       ret = setitimer(ITIMER_REAL, &disarm, NULL);
        if (ret < 0)
            // Should only get here as a result of coding errors.
            semsg(_(e_could_not_clear_timeout_str), strerror(errno));
***************
*** 8398,8404 ****
            semsg(_(e_could_not_reset_handler_for_timeout_str),
                                                              strerror(errno));
      }
!     timeout_flag = 0;
  }
  
  /*
--- 8397,8403 ----
            semsg(_(e_could_not_reset_handler_for_timeout_str),
                                                              strerror(errno));
      }
!     timeout_flag = FALSE;
  }
  
  /*
***************
*** 8412,8418 ****
   * This function is not expected to fail, but if it does it will still return 
a
   * valid flag pointer; the flag will remain stuck as FALSE .
   */
!     volatile int *
  start_timeout(long msec)
  {
      struct itimerval  interval = {
--- 8411,8417 ----
   * This function is not expected to fail, but if it does it will still return 
a
   * valid flag pointer; the flag will remain stuck as FALSE .
   */
!     volatile sig_atomic_t *
  start_timeout(long msec)
  {
      struct itimerval  interval = {
***************
*** 8461,8467 ****
      timer_handler_active = TRUE;
  
      // Set up the interval timer once the alarm handler is in place.
!     ret = setitimer(ITIMER_REAL, &interval, &prev_interval);
      if (ret < 0)
      {
        // Should only get here as a result of coding errors.
--- 8460,8466 ----
      timer_handler_active = TRUE;
  
      // Set up the interval timer once the alarm handler is in place.
!     ret = setitimer(ITIMER_REAL, &interval, NULL);
      if (ret < 0)
      {
        // Should only get here as a result of coding errors.
*** ../vim-8.2.5140/src/proto/os_unix.pro       2022-06-17 15:17:06.304400375 
+0100
--- src/proto/os_unix.pro       2022-06-20 13:08:46.883661913 +0100
***************
*** 87,92 ****
  void xsmp_init(void);
  void xsmp_close(void);
  void stop_timeout(void);
! volatile int *start_timeout(long msec);
  void delete_timer(void);
  /* vim: set ft=c : */
--- 87,92 ----
  void xsmp_init(void);
  void xsmp_close(void);
  void stop_timeout(void);
! volatile sig_atomic_t *start_timeout(long msec);
  void delete_timer(void);
  /* vim: set ft=c : */
*** ../vim-8.2.5140/src/os_win32.c      2022-06-19 14:36:31.798347408 +0100
--- src/os_win32.c      2022-06-20 13:11:00.151509523 +0100
***************
*** 8334,8342 ****
   * deleted. Ping-ponging between the two flags prevents this causing 'fake'
   * timeouts.
   */
! static int      timeout_flags[2];
! static int      timeout_flag_idx = 0;
! static int      *timeout_flag = &timeout_flags[0];
  
  
      static void CALLBACK
--- 8334,8342 ----
   * deleted. Ping-ponging between the two flags prevents this causing 'fake'
   * timeouts.
   */
! static sig_atomic_t timeout_flags[2];
! static int        timeout_flag_idx = 0;
! static sig_atomic_t *timeout_flag = &timeout_flags[0];
  
  
      static void CALLBACK
***************
*** 8378,8384 ****
   * This function is not expected to fail, but if it does it still returns a
   * valid flag pointer; the flag will remain stuck at zero.
   */
!     volatile int *
  start_timeout(long msec)
  {
      BOOL ret;
--- 8378,8384 ----
   * This function is not expected to fail, but if it does it still returns a
   * valid flag pointer; the flag will remain stuck at zero.
   */
!     volatile sig_atomic_t *
  start_timeout(long msec)
  {
      BOOL ret;
*** ../vim-8.2.5140/src/proto/os_win32.pro      2022-06-18 16:48:32.762559984 
+0100
--- src/proto/os_win32.pro      2022-06-20 13:11:03.831505415 +0100
***************
*** 85,89 ****
  void resize_console_buf(void);
  char *GetWin32Error(void);
  void stop_timeout(void);
! volatile int *start_timeout(long msec);
  /* vim: set ft=c : */
--- 85,89 ----
  void resize_console_buf(void);
  char *GetWin32Error(void);
  void stop_timeout(void);
! volatile sig_atomic_t *start_timeout(long msec);
  /* vim: set ft=c : */
*** ../vim-8.2.5140/src/regexp.c        2022-06-19 14:36:31.798347408 +0100
--- src/regexp.c        2022-06-20 13:12:05.099437748 +0100
***************
*** 21,28 ****
  #endif
  
  #ifdef FEAT_RELTIME
! static int dummy_timeout_flag = 0;
! static volatile int *timeout_flag = &dummy_timeout_flag;
  #endif
  
  /*
--- 21,28 ----
  #endif
  
  #ifdef FEAT_RELTIME
! static sig_atomic_t dummy_timeout_flag = 0;
! static volatile sig_atomic_t *timeout_flag = &dummy_timeout_flag;
  #endif
  
  /*
*** ../vim-8.2.5140/src/version.c       2022-06-20 12:39:35.294743603 +0100
--- src/version.c       2022-06-20 13:34:51.477813407 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5141,
  /**/

-- 
BEDEVERE:        And what do you burn, apart from witches?
FOURTH VILLAGER: ... Wood?
BEDEVERE:        So why do witches burn?
SECOND VILLAGER: (pianissimo) ... Because they're made of wood...?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220620123903.2F01A1C075E%40moolenaar.net.

Raspunde prin e-mail lui