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


========================================
[EMAIL PROTECTED] 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

Reply via email to