Patch 8.2.3327
Problem:    No check for sysconf() failing.
Solution:   If sysconf() fails use SIGSTKSZ for the signal stack size.
            (Zdenek Dohnal, closes #8743)
Files:      src/os_unix.c


*** ../vim-8.2.3326/src/os_unix.c       2021-06-23 21:13:17.325564860 +0200
--- src/os_unix.c       2021-08-11 14:17:33.735510397 +0200
***************
*** 783,798 ****
   * completely full.
   */
  
- #if !defined SIGSTKSZ && !defined(HAVE_SYSCONF_SIGSTKSZ)
- # define SIGSTKSZ 8000    // just a guess of how much stack is needed...
- #endif
- 
  # ifdef HAVE_SIGALTSTACK
  static stack_t sigstk;                        // for sigaltstack()
  # else
  static struct sigstack sigstk;                // for sigstack()
  # endif
  
  static char *signal_stack;
  
      static void
--- 783,818 ----
   * completely full.
   */
  
  # ifdef HAVE_SIGALTSTACK
  static stack_t sigstk;                        // for sigaltstack()
  # else
  static struct sigstack sigstk;                // for sigstack()
  # endif
  
+ /*
+  * Get a size of signal stack.
+  * Preference (if available): sysconf > SIGSTKSZ > guessed size
+  */
+ static long int get_signal_stack_size()
+ {
+ # ifdef HAVE_SYSCONF_SIGSTKSZ
+     long int size = -1;
+ 
+     // return size only if sysconf doesn't return an error
+     if ((size = sysconf(_SC_SIGSTKSZ)) > -1)
+       return size;
+ # endif
+ 
+ # ifdef SIGSTKSZ
+     // if sysconf() isn't available or gives error, return SIGSTKSZ
+     // if defined
+     return SIGSTKSZ;
+ # endif
+ 
+     // otherwise guess the size
+     return 8000;
+ }
+ 
  static char *signal_stack;
  
      static void
***************
*** 806,826 ****
  #  else
        sigstk.ss_sp = signal_stack;
  #  endif
! #  ifdef HAVE_SYSCONF_SIGSTKSZ
!       sigstk.ss_size = sysconf(_SC_SIGSTKSZ);
! #  else
!       sigstk.ss_size = SIGSTKSZ;
! #  endif
        sigstk.ss_flags = 0;
        (void)sigaltstack(&sigstk, NULL);
  # else
        sigstk.ss_sp = signal_stack;
        if (stack_grows_downwards)
! #  ifdef HAVE_SYSCONF_SIGSTKSZ
!           sigstk.ss_sp += sysconf(_SC_SIGSTKSZ) - 1;
! #  else
!           sigstk.ss_sp += SIGSTKSZ - 1;
! #  endif
        sigstk.ss_onstack = 0;
        (void)sigstack(&sigstk, NULL);
  # endif
--- 826,838 ----
  #  else
        sigstk.ss_sp = signal_stack;
  #  endif
!       sigstk.ss_size = get_signal_stack_size();
        sigstk.ss_flags = 0;
        (void)sigaltstack(&sigstk, NULL);
  # else
        sigstk.ss_sp = signal_stack;
        if (stack_grows_downwards)
!           sigstk.ss_sp += get_signal_stack_size() - 1;
        sigstk.ss_onstack = 0;
        (void)sigstack(&sigstk, NULL);
  # endif
***************
*** 3278,3288 ****
       * Ignore any errors.
       */
  #if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
! # ifdef HAVE_SYSCONF_SIGSTKSZ
!     signal_stack = alloc(sysconf(_SC_SIGSTKSZ));
! # else
!     signal_stack = alloc(SIGSTKSZ);
! # endif
      init_signal_stack();
  #endif
  }
--- 3290,3296 ----
       * Ignore any errors.
       */
  #if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
!     signal_stack = alloc(get_signal_stack_size());
      init_signal_stack();
  #endif
  }
*** ../vim-8.2.3326/src/version.c       2021-08-10 22:51:59.369449616 +0200
--- src/version.c       2021-08-11 14:19:01.783323507 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3327,
  /**/

-- 
-- 
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/202108111220.17BCKcgj2909884%40masaka.moolenaar.net.

Raspunde prin e-mail lui