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

Forget the buf_T reference when processing a 'close' netbeans command

Expand Messages
  • Xavier de Gaye
    Bug description: =============== Vim version 7.0 When receiving a netbeans close command, vim does delete the specified buffer, but the buffer s reference
    Message 1 of 3 , Aug 3, 2006
      Bug description:
      ===============
      Vim version 7.0

      When receiving a netbeans 'close' command, vim does delete the
      specified buffer, but the buffer's reference (buf_list[bufno].bufp
      called here 'this_memory_address') is still kept in buf_list[].
      It may happen that this_memory_address is once again returned by
      malloc when allocating a new buffer later. In this case, the function
      nb_getbufno(this_memory_address) will return the closed netbeans
      buffer number instead of the newly allocated one since it is always
      before in the list.

      See the test case below.

      Issue:
      How can a netbeans IDE implementation recognize when it talks to a vim
      version where the bug is fixed (since 'close' can't be used when it
      is not fixed) ?
      With a new netbeans version number ?


      Proposed Fix:
      ============
      *** netbeans.c.orig 2006-06-17 18:49:19.000000000 +0200
      --- netbeans.c 2006-08-03 23:25:04.000000000 +0200
      ***************
      *** 1986,1991 ****
      --- 1986,1993 ----
      if (buf->bufp != NULL)
      do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD,
      buf->bufp->b_fnum, TRUE);
      + buf->bufp = NULL;
      + buf->initDone = FALSE;
      doupdate = 1;
      /* =====================================================================*/
      }



      =======================================================================
      Test case:
      =========
      start 'clewn -d'
      open 2 files in vim:
      :e cltest_main.c
      :e cltest_callit.c
      from clewn, 'close' the first one (bufno 2 in the example below) with
      the clewn debug command:
      (gdb) @ 2 close
      open a third file in vim:
      :e cltest_callit_2.c
      hit key 'S' in this last buffer
      result:
      vim reports bufno 2, (the closed buffer), as the buffer where the
      key was pressed instead of bufno 4, (the last buffer)
      this is not always the case, but it is easy to reproduce on my
      linux box


      ========================================
      [xavier@localhost clewn_test]$ clewn -d
      ...
      ... Clewn running GDB in level 3 mode
      ...

      `run' commands do input and output on the terminal /dev/pts/1

      NetBeans listens on localhost:3219

      The netbeans socket to Vim is not connected yet...
      GNU gdb 6.3
      Copyright 2004 Free Software Foundation, Inc.
      GDB is free software, covered by the GNU General Public License, and you are
      welcome to change it and/or distribute copies of it under certain conditions.
      Type "show copying" to see the conditions.
      There is absolutely no warranty for GDB. Type "show warranty" for details.
      This GDB was configured as "i686-pc-linux-gnu".
      NetBeans connected to 127.0.0.1:34015

      AUTH changeme
      0:version=0 "2.3"
      0:startupDone=0
      0:setExitDelay!1 0
      NBS_READY in conn_setup()
      0:fileOpened=0 "/home/xavier/tmp/clewn_test/cltest_main.c" T F
      2:putBufferNumber!2 "/home/xavier/tmp/clewn_test/cltest_main.c"
      2:stopDocumentListen!3
      2:defineAnnoType!4 1 "1" "" "=>" 0 15710005
      2:version!5 "Clewn version 1.1
      ."
      0:fileOpened=0 "/home/xavier/tmp/clewn_test/cltest_callit.c" T F
      3:putBufferNumber!6 "/home/xavier/tmp/clewn_test/cltest_callit.c"
      3:stopDocumentListen!7
      3:defineAnnoType!8 1 "1" "" "=>" 0 15710005
      (gdb) @ 2 close <----- closing bufno 2
      2:close!9
      2:fileOpened=0 "/home/xavier/tmp/clewn_test/cltest_callit_2.c" T F
      4:putBufferNumber!10 "/home/xavier/tmp/clewn_test/cltest_callit_2.c"
      4:stopDocumentListen!11
      4:defineAnnoType!12 1 "1" "" "=>" 0 15710005
      2:newDotAndMark=12 89 89 <----- hitting key 'S' in new buffer (bufno 4)
      2:keyCommand=12 "S"
      2:keyAtPos=12 "S" 89 10/0
      (gdb) step
      The program is not being run.
      (gdb)

      --
      http://clewn.sourceforge.net gdb support in Vim
    • Bram Moolenaar
      ... The fix looks good to me. I ll include the patch and test it a bit. ... Incrementing the netbeans interface version number for this doesn t sound like a
      Message 2 of 3 , Aug 4, 2006
        Xavier de Gaye wrote:

        > Bug description:
        > ===============
        > Vim version 7.0
        >
        > When receiving a netbeans 'close' command, vim does delete the
        > specified buffer, but the buffer's reference (buf_list[bufno].bufp
        > called here 'this_memory_address') is still kept in buf_list[].
        > It may happen that this_memory_address is once again returned by
        > malloc when allocating a new buffer later. In this case, the function
        > nb_getbufno(this_memory_address) will return the closed netbeans
        > buffer number instead of the newly allocated one since it is always
        > before in the list.
        >
        > See the test case below.

        The fix looks good to me. I'll include the patch and test it a bit.

        > Issue:
        > How can a netbeans IDE implementation recognize when it talks to a vim
        > version where the bug is fixed (since 'close' can't be used when it
        > is not fixed) ?
        > With a new netbeans version number ?

        Incrementing the netbeans interface version number for this doesn't
        sound like a good idea. You could test for the patch number when it's
        send out later: has("patch123")

        --
        From "know your smileys":
        ;-0 Can't find shift key
        ,-9 Kann Umschalttaste nicht finden

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
      • Xavier de Gaye
        ... Is there a better way to know what vim version + patches the IDE is talking to, than to do the processing that is equivalent to running the following shell
        Message 3 of 3 , Aug 5, 2006
          --- Bram Moolenaar wrote:

          >
          > Xavier de Gaye wrote:
          >
          > > Bug description:
          > > ===============
          > > Vim version 7.0
          > >
          > > When receiving a netbeans 'close' command, vim does delete the
          > > specified buffer, but the buffer's reference (buf_list[bufno].bufp
          > > called here 'this_memory_address') is still kept in buf_list[].
          > > It may happen that this_memory_address is once again returned by
          > > malloc when allocating a new buffer later. In this case, the function
          > > nb_getbufno(this_memory_address) will return the closed netbeans
          > > buffer number instead of the newly allocated one since it is always
          > > before in the list.
          > >
          > > See the test case below.
          >
          > The fix looks good to me. I'll include the patch and test it a bit.
          >
          > > Issue:
          > > How can a netbeans IDE implementation recognize when it talks to a vim
          > > version where the bug is fixed (since 'close' can't be used when it
          > > is not fixed) ?
          > > With a new netbeans version number ?
          >
          > Incrementing the netbeans interface version number for this doesn't
          > sound like a good idea. You could test for the patch number when it's
          > send out later: has("patch123")


          Is there a better way to know what vim version + patches the IDE is
          talking to, than to do the processing that is equivalent to running the
          following shell commands ?

          $ cmd="let v=version | let p=has(\"patch123\") | let rc=append(line('0'), p) | let
          rc=append(line('0'), v)|wq"
          $ tmp=`mktemp`; echo $cmd | vim -e -s $tmp; cat $tmp; rm $tmp
          700
          0


          Xavier


          --
          http://clewn.sourceforge.net gdb support in Vim
        Your message has been successfully submitted and would be delivered to recipients shortly.