Patch 7.3.520

374 views
Skip to first unread message

Bram Moolenaar

unread,
May 18, 2012, 11:03:31 AM5/18/12
to vim...@googlegroups.com

Patch 7.3.520
Problem: Gvim starts up slow on Unbuntu 12.04.
Solution: Move the call to gui_mch_init_check() to after fork(). (Yasuhiro
Matsumoto) Do check $DISPLAY being set.
Files: src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro


*** ../vim-7.3.519/src/gui.c 2011-10-20 21:27:57.000000000 +0200
--- src/gui.c 2012-05-18 16:53:14.000000000 +0200
***************
*** 270,275 ****
--- 270,281 ----
}
/* Child */

+ #ifdef FEAT_GUI_GTK
+ /* Call gtk_init_check() here after fork(). See gui_init_check(). */
+ if (gui_mch_init_check() != OK)
+ exit(1);
+ #endif
+
# if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
/*
* Change our process group. On some systems/shells a CTRL-C in the
***************
*** 430,436 ****
--- 436,452 ----
#ifdef ALWAYS_USE_GUI
result = OK;
#else
+ # ifdef FEAT_GUI_GTK
+ /*
+ * Note: Don't call gtk_init_check() before fork, it will be called after
+ * the fork. When calling it before fork, it make vim hang for a while.
+ * See gui_do_fork().
+ * Use a simpler check if the GUI window can probably be opened.
+ */
+ result = gui.dofork ? gui_mch_early_init_check() : gui_mch_init_check();
+ # else
result = gui_mch_init_check();
+ # endif
#endif
return result;
}
*** ../vim-7.3.519/src/gui_gtk_x11.c 2011-10-26 11:36:21.000000000 +0200
--- src/gui_gtk_x11.c 2012-05-18 17:00:45.000000000 +0200
***************
*** 1414,1420 ****
}

/*
! * Check if the GUI can be started. Called before gvimrc is sourced.
* Return OK or FAIL.
*/
int
--- 1414,1442 ----
}

/*
! * Check if the GUI can be started. Called before gvimrc is sourced and
! * before fork().
! * Return OK or FAIL.
! */
! int
! gui_mch_early_init_check(void)
! {
! char_u *p;
!
! /* Guess that when $DISPLAY isn't set the GUI can't start. */
! p = mch_getenv((char_u *)"DISPLAY");
! if (p == NULL || *p == NUL)
! {
! gui.dying = TRUE;
! EMSG(_((char *)e_opendisp));
! return FAIL;
! }
! return OK;
! }
!
! /*
! * Check if the GUI can be started. Called before gvimrc is sourced but after
! * fork().
* Return OK or FAIL.
*/
int
***************
*** 3050,3056 ****

for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
{
! /* OpenOffice tries to use TARGET_HTML and fails when it doesn't
* return something, instead of trying another target. Therefore only
* offer TARGET_HTML when it works. */
if (!clip_html && selection_targets[i].info == TARGET_HTML)
--- 3072,3078 ----

for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
{
! /* OpenOffice tries to use TARGET_HTML and fails when we don't
* return something, instead of trying another target. Therefore only
* offer TARGET_HTML when it works. */
if (!clip_html && selection_targets[i].info == TARGET_HTML)
*** ../vim-7.3.519/src/proto/gui_gtk_x11.pro 2011-08-10 17:44:41.000000000 +0200
--- src/proto/gui_gtk_x11.pro 2012-05-18 16:54:28.000000000 +0200
***************
*** 4,9 ****
--- 4,10 ----
void gui_mch_set_blinking __ARGS((long waittime, long on, long off));
void gui_mch_stop_blink __ARGS((void));
void gui_mch_start_blink __ARGS((void));
+ int gui_mch_early_init_check __ARGS((void));
int gui_mch_init_check __ARGS((void));
void gui_mch_show_tabline __ARGS((int showit));
int gui_mch_showing_tabline __ARGS((void));
*** ../vim-7.3.519/src/version.c 2012-05-18 16:35:17.000000000 +0200
--- src/version.c 2012-05-18 16:45:30.000000000 +0200
***************
*** 716,717 ****
--- 716,719 ----
{ /* Add new patch number below this line */
+ /**/
+ 520,
/**/

--
Bad programs can be written in any language.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Davido

unread,
May 19, 2012, 6:24:08 AM5/19/12
to vim...@googlegroups.com
> Patch 7.3.520
> Problem: Gvim starts up slow on Unbuntu 12.04.
> Solution: Move the call to gui_mch_init_check() to after fork(). (Yasuhiro
> Matsumoto) Do check $DISPLAY being set.
> Files: src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro

Hello,

I'm trying to upgrade from version 7.3.515 (which works perfectly)
to 7.3.524 on an ubuntu 12.04. Vim compiles, but crashes if I launch
gvim without the -f flag. The warning messages (see below) seem to be
related with this patch.

Let's point out that the terminal variant and "./src/vim -gf" work
properly, as far as I've tested.

> $ ./src/vim -g
>
> (process:12589): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.32.1/./gobject/gtype.c:2722: You forgot to call g_type_init()
>
> (process:12589): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.32.1/./gobject/gtype.c:2722: You forgot to call g_type_init()
>
> (process:12589): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
>
> (process:12589): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
>
> (process:12589): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
> (process:12589): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
>
> (process:12589): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
>
> (process:12589): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.32.1/./gobject/gtype.c:2722: You forgot to call g_type_init()
>
> (process:12589): GLib-GObject-CRITICAL **: /build/buildd/glib2.0-2.32.1/./gobject/gtype.c:2722: You forgot to call g_type_init()
>
> (process:12589): GLib-GObject-CRITICAL **: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
>
> (process:12589): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
>
> (process:12589): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
>
> (process:12589): GLib-CRITICAL **: g_once_init_leave: assertion `result != 0' failed
>
> (process:12589): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
> Vim : Signal mortel SEGV intercepté
> Vim : Fini.
> 31;0Mzsh: segmentation fault (core dumped) ./src/vim -g

I post also the output of :version, in case it's useful :

> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 19 2012 11:51:40)
> Included patches : 1-524
> Huge version with graphical interface GTK2. Included (+) or not (-) :
> +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info
> +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra
> +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap
> +langmap +libcall +linebreak +lispindent +listcmds +localmap +lua/dyn +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm
> -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg +path_extra +perl
> +persistent_undo +postscript +printer +profile +python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent +sniff
> +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white +tcl +terminfo +termresponse +textobjects +title
> +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11
> -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save
> System vimrc : "$VIM/vimrc"
> User vimrc : "$HOME/.vimrc"
> User exrc : "$HOME/.exrc"
> System gvimrc : "$VIM/gvimrc"
> User gvimrc : "$HOME/.gvimrc"
> System menu file : "$VIMRUNTIME/menu.vim"
> $VIM par défaut : "/usr/local/share/vim"
> Compilation : /usr/bin/gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/local/include -O2 -march=native -mtune=native -Wall -Wstrict-prototypes -v -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.5 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
> Linking : /usr/bin/gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee -lm -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib

--
Regards,

Davido

Bram Moolenaar

unread,
May 20, 2012, 7:28:01 AM5/20/12
to Davido, vim...@googlegroups.com, mattn

Davido wrote:

> > Patch 7.3.520
> > Problem: Gvim starts up slow on Unbuntu 12.04.
> > Solution: Move the call to gui_mch_init_check() to after fork(). (Yasuhiro
> > Matsumoto) Do check $DISPLAY being set.
> > Files: src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro
>
> Hello,
>
> I'm trying to upgrade from version 7.3.515 (which works perfectly)
> to 7.3.524 on an ubuntu 12.04. Vim compiles, but crashes if I launch
> gvim without the -f flag. The warning messages (see below) seem to be
> related with this patch.
>
> Let's point out that the terminal variant and "./src/vim -gf" work
> properly, as far as I've tested.

That's weird, that patch was supposed to fix this kind of problem.

Yasuhiro, any idea?

--
Eye have a spelling checker, it came with my PC;
It plainly marks four my revue mistakes I cannot sea.
I've run this poem threw it, I'm sure your please to no,
It's letter perfect in it's weigh, my checker tolled me sew!

Dominique Pellé

unread,
May 20, 2012, 7:47:23 AM5/20/12
to vim...@googlegroups.com
Bram Moolenaar <Br...@moolenaar.net> wrote:

> Davido wrote:
>
>> > Patch 7.3.520
>> > Problem:    Gvim starts up slow on Unbuntu 12.04.
>> > Solution:   Move the call to gui_mch_init_check() to after fork(). (Yasuhiro
>> >         Matsumoto)  Do check $DISPLAY being set.
>> > Files:          src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro
>>
>> Hello,
>>
>> I'm trying to upgrade from version 7.3.515 (which works perfectly)
>> to 7.3.524 on an ubuntu 12.04. Vim compiles, but crashes if I launch
>> gvim without the -f flag. The warning messages (see below) seem to be
>> related with this patch.
>>
>> Let's point out that the terminal variant and "./src/vim -gf" work
>> properly, as far as I've tested.
>
> That's weird, that patch was supposed to fix this kind of problem.
>
> Yasuhiro, any idea?


It works fine for me at least using Vim-7.3.524 (huge) on xubuntu-12.04.

-- Dominique

Davido

unread,
May 20, 2012, 9:46:33 AM5/20/12
to vim...@googlegroups.com
I'm using pekwm as window manager for more than a year, but I never
encountered any problem with vim-gtk.

So, I've run some tests, found that my particular set of options (which
didn't cause any trouble until version 7.3.519 included) is somehow
interfering with this patch.

Fortunetly, I found which option is responsible of this issue : all
works well if I remove the "f" flag from "guioptions". Don't ask me
why, however.

Thanks for your kind replies.

--
Regards,

Davido

Dominique Pellé

unread,
May 20, 2012, 6:32:27 PM5/20/12
to vim...@googlegroups.com
I can confirm. I can now reproduce the crash on xubuntu-12.04
by adding in my ~/.vimrc:

set guioptions=f

-- Dominique

mattn

unread,
May 20, 2012, 8:16:39 PM5/20/12
to vim...@googlegroups.com
Hmm, I can't reproduce it.

gtk_init_check must be called at child process. So if "You forgot to call g_type_init()" appear, I guess that it's shown in parent process.

Could you try to get stacktrace with gdb?

mattn

unread,
May 20, 2012, 8:28:18 PM5/20/12
to vim...@googlegroups.com
In additional comment, try to start ./src/vim -g -u NONE.

mattn

unread,
May 20, 2012, 9:40:37 PM5/20/12
to vim...@googlegroups.com
Ok, I could fix it.

diff -r d915c19ad092 src/gui.c
--- a/src/gui.c Fri May 18 21:54:13 2012 +0200
+++ b/src/gui.c Mon May 21 10:39:49 2012 +0900
@@ -102,6 +102,12 @@
else
#endif
{
+ /*
+ * If there is 'f' in 'guioptions' and specify -g argument,
+ * gui_mch_init_check() isn't called yet.
+ */
+ if (gui_mch_init_check() != OK)
+ exit(1);
gui_attempt_start();

Davido

unread,
May 21, 2012, 5:40:46 AM5/21/12
to vim...@googlegroups.com
> Ok, I could fix it.
>
> diff -r d915c19ad092 src/gui.c
> --- a/src/gui.c Fri May 18 21:54:13 2012 +0200
> +++ b/src/gui.c Mon May 21 10:39:49 2012 +0900
> @@ -102,6 +102,12 @@
> else
> #endif
> {
> + /*
> + * If there is 'f' in 'guioptions' and specify -g argument,
> + * gui_mch_init_check() isn't called yet.
> + */
> + if (gui_mch_init_check() != OK)
> + exit(1);
> gui_attempt_start();
> }

Glad you found a solution !

By the way, "./src/vim -g -u NONE" works perfectly.

I guess the backtrace is no longer necessary (?)

--
Regards,
Davido

mattn

unread,
May 21, 2012, 5:51:06 AM5/21/12
to vim...@googlegroups.com
> By the way, "./src/vim -g -u NONE" works perfectly.
>
> I guess the backtrace is no longer necessary (?)

Ah, sorry. no need to do it. thanks.

Reply all
Reply to author
Forward
0 new messages