Loading ...
Sorry, an error occurred while loading the content.

Re: Weird ( . 1510 search pattern (or ruby?) bug

Expand Messages
  • Bram Moolenaar
    ... We first need to be able to catch the stack overflow. But this sounds a bit complicated. It would be much easier if we can check how much stack space is
    Message 1 of 5 , Dec 31, 2002
    • 0 Attachment
      George Reilly wrote:

      > With MSVCRT, you can use _resetstkoflw() in an exception handler to deal
      > with stack overflows:
      > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/
      > vclrf_resetstkoflw.asp. However, it's much easier to handle allocation
      > failures from malloc(). Also, _resetstkoflow() may not be available on other
      > Win32 compilers, such as Borland or Ming32.

      We first need to be able to catch the stack overflow. But this sounds a
      bit complicated. It would be much easier if we can check how much stack
      space is left, so that we can abort the regexp code when we are running
      out. For Unix this is done with get_stack_limit() in os_unix.c.

      > By default, the stack size is 1MB. This can be adjusted by the /STACK option
      > to the linker. Or adjusted after the fact with EDITBIN.
      > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html
      > /_core_.2f.STACK_linker.asp

      This only helps to make the problem appear in less situations, it's not
      a useful fix.

      > The stack is not the right resource for huge allocations; the heap is. If
      > _alloca() really makes a noticeable difference for the common case, I'd
      > suggest some kind of hybrid scheme where you allocate the first few thousand
      > bytes from the stack and fall back on the heap thereafter.

      I know, I know. The regexp code was written to do recursive calls.
      Thus it's a matter of very many small allocations. Rewriting it to
      allocate memory with malloc() instead would be a huge task.

      --
      hundred-and-one symptoms of being an internet addict:
      237. You tattoo your email address on your forehead.

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.vim.org \\\
      \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
      \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.