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

Crash when extend(o, o)

Expand Messages
  • mattn
    When passing same Dictionary/List to expand(), it breaks reference counter. let o = { a :{ b : B }} call extend(o, o) echo o.a.b
    Message 1 of 5 , May 2, 2012
    • 0 Attachment
      When passing same Dictionary/List to expand(), it breaks reference counter.

      let o = {"a":{"b":"B"}}
      call extend(o, o)
      echo o.a.b <= crash

      https://gist.github.com/2578755

      Please check and include.

      diff -r 8201108e9cf0 src/eval.c
      --- a/src/eval.c Tue May 01 21:14:34 2012 +0200
      +++ b/src/eval.c Thu May 03 03:00:30 2012 +0900
      @@ -10110,7 +10110,7 @@
      l1 = argvars[0].vval.v_list;
      l2 = argvars[1].vval.v_list;
      if (l1 != NULL && !tv_check_lock(l1->lv_lock, (char_u *)_(arg_errmsg))
      - && l2 != NULL)
      + && l2 != NULL && l1 != l2)
      {
      if (argvars[2].v_type != VAR_UNKNOWN)
      {
      @@ -10149,7 +10149,7 @@
      d1 = argvars[0].vval.v_dict;
      d2 = argvars[1].vval.v_dict;
      if (d1 != NULL && !tv_check_lock(d1->dv_lock, (char_u *)_(arg_errmsg))
      - && d2 != NULL)
      + && d2 != NULL && d1 != d2)
      {
      /* Check the third argument. */
      if (argvars[2].v_type != VAR_UNKNOWN)
      @@ -10191,7 +10191,7 @@
      EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
      break;
      }
      - else if (*action == 'f')
      + else if (*action == 'f' && HI2DI(hi2) != di1)
      {
      clear_tv(&di1->di_tv);
      copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);

      --
      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
    • Bram Moolenaar
      ... Thanks for the fix! Can you also write a test for this? -- Snoring is prohibited unless all bedroom windows are closed and securely locked. [real standing
      Message 2 of 5 , May 2, 2012
      • 0 Attachment
        Yasohiro Matsumoto wrote:

        > When passing same Dictionary/List to expand(), it breaks reference counter.
        >
        > let o = {"a":{"b":"B"}}
        > call extend(o, o)
        > echo o.a.b <= crash
        >
        > https://gist.github.com/2578755
        >
        > Please check and include.

        Thanks for the fix! Can you also write a test for this?

        --
        Snoring is prohibited unless all bedroom windows are closed and securely
        locked.
        [real standing law in Massachusetts, United States of America]

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ 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
      • h_east
        ... Hi Bram, Patch modified and test added. eval.c patch author is Thinca. test patch author is me. (I have got consent from Yasuhiro Matsumoto.) Please check.
        Message 3 of 5 , May 5, 2012
        • 0 Attachment
          2012/5/3 (Thu) 3:55:50 UTC+9 Bram Moolenaar:
          > Yasohiro Matsumoto wrote:
          >
          > > When passing same Dictionary/List to expand(), it breaks reference counter.
          > >
          > > let o = {"a":{"b":"B"}}
          > > call extend(o, o)
          > > echo o.a.b <= crash
          > >
          > > https://gist.github.com/2578755
          > >
          > > Please check and include.
          >
          > Thanks for the fix! Can you also write a test for this?

          Hi Bram,

          Patch modified and test added.
          eval.c patch author is Thinca.
          test patch author is me.
          (I have got consent from Yasuhiro Matsumoto.)

          Please check.

          Regards,
          --
          Hirohito Higashi

          --
          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
        • mattn
          Thanks Hirohito. Bram, this original patch is writen by thinca. And tests above is writen by Hirohito. ... -- You received this message from the vim_dev
          Message 4 of 5 , May 5, 2012
          • 0 Attachment
            Thanks Hirohito.

            Bram, this original patch is writen by thinca. And tests above is writen by Hirohito.

            On Saturday, May 5, 2012 11:59:03 PM UTC+9, h_east wrote:
            > 2012/5/3 (Thu) 3:55:50 UTC+9 Bram Moolenaar:
            > > Yasohiro Matsumoto wrote:
            > >
            > > > When passing same Dictionary/List to expand(), it breaks reference counter.
            > > >
            > > > let o = {"a":{"b":"B"}}
            > > > call extend(o, o)
            > > > echo o.a.b <= crash
            > > >
            > > > https://gist.github.com/2578755
            > > >
            > > > Please check and include.
            > >
            > > Thanks for the fix! Can you also write a test for this?
            >
            > Hi Bram,
            >
            > Patch modified and test added.
            > eval.c patch author is Thinca.
            > test patch author is me.
            > (I have got consent from Yasuhiro Matsumoto.)
            >
            > Please check.
            >
            > Regards,
            > --
            > Hirohito Higashi

            --
            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
          • Bram Moolenaar
            ... Thanks! I will look into it soon. -- Living on Earth includes an annual free trip around the Sun. /// Bram Moolenaar -- Bram@Moolenaar.net --
            Message 5 of 5 , May 6, 2012
            • 0 Attachment
              Hirohito Higashi wrote:

              > 2012/5/3 (Thu) 3:55:50 UTC+9 Bram Moolenaar:
              > > Yasohiro Matsumoto wrote:
              > >
              > > > When passing same Dictionary/List to expand(), it breaks reference counter.
              > > >
              > > > let o = {"a":{"b":"B"}}
              > > > call extend(o, o)
              > > > echo o.a.b <= crash
              > > >
              > > > https://gist.github.com/2578755
              > > >
              > > > Please check and include.
              > >
              > > Thanks for the fix! Can you also write a test for this?
              >
              > Hi Bram,
              >
              > Patch modified and test added.
              > eval.c patch author is Thinca.
              > test patch author is me.
              > (I have got consent from Yasuhiro Matsumoto.)

              Thanks! I will look into it soon.

              --
              Living on Earth includes an annual free trip around the Sun.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ 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
            Your message has been successfully submitted and would be delivered to recipients shortly.