Hi Attached patch fixes a bug with Vim-7.2.30 when built with GUI GTK with -DEXITFREE (configure --with-features=huge --enable-gui=gtk). It's a low priority bug since Vim is normally not built with -DEXITFREE. Only GTK GUI is affected (GTK2, athena, Motif are OK).
>From what I see, GTK takes care of calling XCloseDisplay() through atexit() so mch_free_mem() in os_unix.c should not call XCloseDisplay() before exit() is being called. Here is the error (among other errors) reported by valgrind memory checker: ==12828== Invalid read of size 4 ==12828== at 0x4431EE7: XCloseDisplay (in /usr/lib/libX11.so.6.2.0) ==12828== by 0x418F31E: (within /usr/lib/libgdk-1.2.so.0.9.1) ==12828== by 0x42F7083: exit (in /lib/tls/i686/cmov/libc-2.7.so) ==12828== by 0x8169EF0: mch_exit (os_unix.c:3060) ==12828== by 0x8104D20: getout (main.c:1340) ==12828== by 0x80CA8EE: ex_quit_all (ex_docmd.c:6281) ==12828== by 0x80C4994: do_one_cmd (ex_docmd.c:2621) ==12828== by 0x80C2215: do_cmdline (ex_docmd.c:1095) ==12828== by 0x8148D60: nv_colon (normal.c:5217) ==12828== by 0x8142301: normal_cmd (normal.c:1184) ==12828== by 0x8104A53: main_loop (main.c:1179) ==12828== by 0x810459B: main (main.c:938) ==12828== Address 0x45943b4 is 148 bytes inside a block of size 1,340 free'd ==12828== at 0x402268C: free (vg_replace_malloc.c:323) ==12828== by 0x4444F3E: _XFreeDisplayStructure (in /usr/lib/libX11.so.6.2.0) ==12828== by 0x4431FC5: XCloseDisplay (in /usr/lib/libX11.so.6.2.0) ==12828== by 0x8169D73: mch_free_mem (os_unix.c:2945) ==12828== by 0x813289B: free_all_mem (misc2.c:1122) ==12828== by 0x8169EE5: mch_exit (os_unix.c:3057) ==12828== by 0x8104D20: getout (main.c:1340) ==12828== by 0x80CA8EE: ex_quit_all (ex_docmd.c:6281) ==12828== by 0x80C4994: do_one_cmd (ex_docmd.c:2621) ==12828== by 0x80C2215: do_cmdline (ex_docmd.c:1095) ==12828== by 0x8148D60: nv_colon (normal.c:5217) ==12828== by 0x8142301: normal_cmd (normal.c:1184) ==12828== by 0x8104A53: main_loop (main.c:1179) ==12828== by 0x810459B: main (main.c:938) Attached patch fixes it. -- Dominique --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
Index: os_unix.c =================================================================== RCS file: /cvsroot/vim/vim7/src/os_unix.c,v retrieving revision 1.85 diff -c -r1.85 os_unix.c *** os_unix.c 6 Aug 2008 16:45:01 -0000 1.85 --- os_unix.c 7 Nov 2008 19:34:04 -0000 *************** *** 2937,2948 **** # endif # endif # ifdef FEAT_X11 if (x11_display != NULL ! # ifdef FEAT_XCLIPBOARD && x11_display != xterm_dpy ! # endif ) XCloseDisplay(x11_display); # endif # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) vim_free(signal_stack); --- 2937,2952 ---- # endif # endif # ifdef FEAT_X11 + /* Don't call XCloseDisplay() for GUI GTK without HAVE_GTK2, it + * already calls it in atexit() */ + # if !defined(FEAT_GUI_GTK) || defined(HAVE_GTK2) if (x11_display != NULL ! # ifdef FEAT_XCLIPBOARD && x11_display != xterm_dpy ! # endif ) XCloseDisplay(x11_display); + # endif # endif # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) vim_free(signal_stack);