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

56636Re: BUG: Vim always crashes with some steps

Expand Messages
  • Dominique Pellé
    Apr 30, 2010
    • 0 Attachment
      Bram Moolenaar wrote:

      > Yukihiro Nakadaira wrote:
      >> Kana Natsuno wrote:
      >> > On Mon, 12 Oct 2009 05:03:27 +0900, Bram Moolenaar <Bram@...> wrote:
      >> >> Can you somehow simplify the way to reproduce this and send me the Vim
      >> >> script for this?
      >> >
      >> > Sorry, I tried to simplify before reporting but failed.  Because the
      >> > problem I encountered seems to depend on the number/order of operations,
      >> > and the problem doesn't occur even if I delete a key/value pair
      >> > expression from dictionary literal which seems not to be related to
      >> > executing scripts.
      >> >
      >> > Anyway, I'll try to simplify again.
      >> Perhaps your problem is ...
      >> In eval.c, all "s:" dictionary is stored in one array (ga_scripts).
      >> When new script file is sourced, the array is re-allocated for new "s:"
      >> dictionary.  Then "s:" dictionary, previously assigned to other variable
      >> (e.g. :let g:foo = s:), will become an invalid pointer.
      >> Script to reproduce: (might not crash 100%)
      >>    let script_vars = []
      >>    for src in range(10)
      >>      call writefile(['call add(script_vars, s:)'], src)
      >>      source `=src`
      >>      " allocate memory to ensure crash.
      >>      call repeat(' ', 1000)
      >>    endfor
      >>    echo script_vars
      > Very good point.  Thanks for finding this problem.  I'll think about a
      > solution.  Unless someone beats me to it.


      Crash in eval.c described above was reported a long time ago.

      Attached patch fixes it by making ga_scripts in eval.c a growing
      array of pointers "scriptvar_T *" rather than growing array of
      structs "scriptvar_T" so that when ga_scripts is reallocated,
      structures don't move in memory.

      I verified that the sample script given by Yukihiro Nakadaira which
      always caused a crash (and errors with Valgrind) no longer crashes
      after patch (and Valgrind no complain either).

      -- Dominique

      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
    • Show all 8 messages in this topic