From: "Jan Djärv" <jan.h.d@swipnet.se>
To: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: 9830@debbugs.gnu.org
Subject: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory
Date: Sun, 30 Oct 2011 18:41:40 +0100 [thread overview]
Message-ID: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> (raw)
In-Reply-To: <wlaa8tod80.wl%mituharu@math.s.chiba-u.ac.jp>
Hello.
22 okt 2011 kl. 06:35 skrev YAMAMOTO Mitsuharu:
> Currently, xdialog_show in xmenu.c calls
> free_menubar_widget_value_tree after calling create_and_show_dialog:
>
> /* Actually create and show the dialog. */
> create_and_show_dialog (f, first_wv);
>
> /* Free the widget_value objects we used to specify the contents. */
> free_menubar_widget_value_tree (first_wv);
>
> But create_and_show_dialog may longjmp in the following case:
>
> (let (last-nonmenu-event)
> (y-or-n-p-with-timeout "test" 3 'default))
> ;; wait 3 seconds.
>
> In this case, free_menubar_widget_value_tree is not called and the
> memory allocated for `first_wv' is leaked.
>
> The patch below uses record_unwind_protect as usual for avoiding this
> memory leak. I think xmenu_show has the same problem. I'm not sure
> about the W32 case.
>
You are correct. Can you install the patch?
As for xmenu_show, is there a case where a menu can be interrupted like this?
Jan D.
> YAMAMOTO Mitsuharu
> mituharu@math.s.chiba-u.ac.jp
>
> === modified file 'src/xmenu.c'
> *** src/xmenu.c 2011-05-09 11:13:02 +0000
> --- src/xmenu.c 2011-10-22 02:14:19 +0000
> ***************
> *** 1658,1663 ****
> --- 1658,1674 ----
>
> #endif /* not USE_GTK */
>
> + static Lisp_Object
> + cleanup_widget_value_tree (Lisp_Object arg)
> + {
> + struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
> + widget_value *wv = p->pointer;
> +
> + free_menubar_widget_value_tree (wv);
> +
> + return Qnil;
> + }
> +
> Lisp_Object
> xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
> Lisp_Object title, char **error, EMACS_UINT timestamp)
> ***************
> *** 1672,1677 ****
> --- 1683,1690 ----
>
> int first_pane;
>
> + int specpdl_count = SPECPDL_INDEX ();
> +
> if (! FRAME_X_P (f))
> abort ();
>
> ***************
> *** 1866,1876 ****
> /* No selection has been chosen yet. */
> menu_item_selection = 0;
>
> /* Actually create and show the menu until popped down. */
> create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp);
>
> ! /* Free the widget_value objects we used to specify the contents. */
> ! free_menubar_widget_value_tree (first_wv);
>
> /* Find the selected item, and its pane, to return
> the proper value. */
> --- 1879,1893 ----
> /* No selection has been chosen yet. */
> menu_item_selection = 0;
>
> + /* Make sure to free the widget_value objects we used to specify the
> + contents even with longjmp. */
> + record_unwind_protect (cleanup_widget_value_tree,
> + make_save_value (first_wv, 0));
> +
> /* Actually create and show the menu until popped down. */
> create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp);
>
> ! unbind_to (specpdl_count, Qnil);
>
> /* Find the selected item, and its pane, to return
> the proper value. */
> ***************
> *** 2064,2069 ****
> --- 2081,2088 ----
> /* 1 means we've seen the boundary between left-hand elts and right-hand. */
> int boundary_seen = 0;
>
> + int specpdl_count = SPECPDL_INDEX ();
> +
> if (! FRAME_X_P (f))
> abort ();
>
> ***************
> *** 2177,2187 ****
> /* No selection has been chosen yet. */
> menu_item_selection = 0;
>
> /* Actually create and show the dialog. */
> create_and_show_dialog (f, first_wv);
>
> ! /* Free the widget_value objects we used to specify the contents. */
> ! free_menubar_widget_value_tree (first_wv);
>
> /* Find the selected item, and its pane, to return
> the proper value. */
> --- 2196,2210 ----
> /* No selection has been chosen yet. */
> menu_item_selection = 0;
>
> + /* Make sure to free the widget_value objects we used to specify the
> + contents even with longjmp. */
> + record_unwind_protect (cleanup_widget_value_tree,
> + make_save_value (first_wv, 0));
> +
> /* Actually create and show the dialog. */
> create_and_show_dialog (f, first_wv);
>
> ! unbind_to (specpdl_count, Qnil);
>
> /* Find the selected item, and its pane, to return
> the proper value. */
>
>
>
> In GNU Emacs 23.3.50.1 (x86_64-apple-darwin10.8.0, GTK+ Version 2.24.6)
> of 2011-10-20 on yamamoto-mitsuharu-no-iMac.local
> Windowing system distributor `The X.Org Foundation', version 11.0.10402000
> configured using `configure '--enable-checking' 'LDFLAGS=-L/opt/local/lib' 'CPPFLAGS=-I/opt/local/include' 'CFLAGS=-g''
>
> Important settings:
> value of $LC_ALL: nil
> value of $LC_COLLATE: nil
> value of $LC_CTYPE: nil
> value of $LC_MESSAGES: nil
> value of $LC_MONETARY: nil
> value of $LC_NUMERIC: nil
> value of $LC_TIME: nil
> value of $LANG: ja_JP.UTF-8
> value of $XMODIFIERS: nil
> locale-coding-system: utf-8-unix
> default enable-multibyte-characters: t
>
> Major mode: Fundamental
>
> Minor modes in effect:
> tooltip-mode: t
> mouse-wheel-mode: t
> tool-bar-mode: t
> menu-bar-mode: t
> file-name-shadow-mode: t
> blink-cursor-mode: t
> auto-encryption-mode: t
> auto-compression-mode: t
> line-number-mode: t
> transient-mark-mode: t
>
>
>
next prev parent reply other threads:[~2011-10-30 17:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-22 4:35 bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory YAMAMOTO Mitsuharu
2011-10-30 17:41 ` Jan Djärv [this message]
2011-10-31 3:21 ` YAMAMOTO Mitsuharu
2011-11-06 15:54 ` Jan Djärv
2011-11-06 23:39 ` Glenn Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se \
--to=jan.h.d@swipnet.se \
--cc=9830@debbugs.gnu.org \
--cc=mituharu@math.s.chiba-u.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.