From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Newsgroups: gmane.emacs.bugs 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 Message-ID: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1319996530 31019 80.91.229.12 (30 Oct 2011 17:42:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 30 Oct 2011 17:42:10 +0000 (UTC) Cc: 9830@debbugs.gnu.org To: YAMAMOTO Mitsuharu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 30 18:42:05 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RKZOS-0000mI-Gr for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Oct 2011 18:42:00 +0100 Original-Received: from localhost ([::1]:35110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKZOR-0007H0-W4 for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Oct 2011 13:41:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKZOP-0007Gm-JS for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2011 13:41:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKZON-0000EC-Sp for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2011 13:41:57 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:32955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKZON-0000E2-ID for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2011 13:41:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RKZQP-0001Cf-VQ for bug-gnu-emacs@gnu.org; Sun, 30 Oct 2011 13:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jan =?UTF-8?Q?Dj=C3=A4rv?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Oct 2011 17:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9830 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9830-submit@debbugs.gnu.org id=B9830.13199966324604 (code B ref 9830); Sun, 30 Oct 2011 17:44:01 +0000 Original-Received: (at 9830) by debbugs.gnu.org; 30 Oct 2011 17:43:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKZQG-0001CA-Bf for submit@debbugs.gnu.org; Sun, 30 Oct 2011 13:43:52 -0400 Original-Received: from mail-bw0-f44.google.com ([209.85.214.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKZQD-0001C2-3Z for 9830@debbugs.gnu.org; Sun, 30 Oct 2011 13:43:51 -0400 Original-Received: by bkat8 with SMTP id t8so640838bka.3 for <9830@debbugs.gnu.org>; Sun, 30 Oct 2011 10:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=EOI05fPeXyCifcPIaIgAUdhfZh4jsLmcOU9ep5cfpPU=; b=JteETndnT3JZHzQWRTKIVpeyQw90oN/RqBnCtG/wB3O6PUHw/fotFK7/SedW23b7hN je2EXm8uwvLIUpodxu9girnzF6WMIDimqACK6JsyBya8J7Bb3IvNbeMOXm+5GpqWGEBr Ev6DpqFwdDLJDxqJJceSI7Ii8ua9TQ5oSEb4o= Original-Received: by 10.204.130.208 with SMTP id u16mr8247170bks.47.1319996501237; Sun, 30 Oct 2011 10:41:41 -0700 (PDT) Original-Received: from [172.20.199.13] (c-c92de155.25-1-64736c10.cust.bredbandsbolaget.se. [85.225.45.201]) by mx.google.com with ESMTPS id j9sm14389106bkd.2.2011.10.30.10.41.39 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 30 Oct 2011 10:41:40 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.1251.1) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 30 Oct 2011 13:44:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:53327 Archived-At: 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: >=20 > /* Actually create and show the dialog. */ > create_and_show_dialog (f, first_wv); >=20 > /* Free the widget_value objects we used to specify the contents. */ > free_menubar_widget_value_tree (first_wv); >=20 > But create_and_show_dialog may longjmp in the following case: >=20 > (let (last-nonmenu-event) > (y-or-n-p-with-timeout "test" 3 'default)) > ;; wait 3 seconds. >=20 > In this case, free_menubar_widget_value_tree is not called and the > memory allocated for `first_wv' is leaked. >=20 > 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. >=20 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 >=20 > =3D=3D=3D 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 ---- >=20 > #endif /* not USE_GTK */ >=20 > + static Lisp_Object > + cleanup_widget_value_tree (Lisp_Object arg) > + { > + struct Lisp_Save_Value *p =3D XSAVE_VALUE (arg); > + widget_value *wv =3D p->pointer; > +=20 > + free_menubar_widget_value_tree (wv); > +=20 > + return Qnil; > + } > +=20 > 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 ---- >=20 > int first_pane; >=20 > + int specpdl_count =3D SPECPDL_INDEX (); > +=20 > if (! FRAME_X_P (f)) > abort (); >=20 > *************** > *** 1866,1876 **** > /* No selection has been chosen yet. */ > menu_item_selection =3D 0; >=20 > /* Actually create and show the menu until popped down. */ > create_and_show_popup_menu (f, first_wv, x, y, for_click, = timestamp); >=20 > ! /* Free the widget_value objects we used to specify the contents. = */ > ! free_menubar_widget_value_tree (first_wv); >=20 > /* Find the selected item, and its pane, to return > the proper value. */ > --- 1879,1893 ---- > /* No selection has been chosen yet. */ > menu_item_selection =3D 0; >=20 > + /* 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)); > +=20 > /* Actually create and show the menu until popped down. */ > create_and_show_popup_menu (f, first_wv, x, y, for_click, = timestamp); >=20 > ! unbind_to (specpdl_count, Qnil); >=20 > /* 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 =3D 0; >=20 > + int specpdl_count =3D SPECPDL_INDEX (); > +=20 > if (! FRAME_X_P (f)) > abort (); >=20 > *************** > *** 2177,2187 **** > /* No selection has been chosen yet. */ > menu_item_selection =3D 0; >=20 > /* Actually create and show the dialog. */ > create_and_show_dialog (f, first_wv); >=20 > ! /* Free the widget_value objects we used to specify the contents. = */ > ! free_menubar_widget_value_tree (first_wv); >=20 > /* Find the selected item, and its pane, to return > the proper value. */ > --- 2196,2210 ---- > /* No selection has been chosen yet. */ > menu_item_selection =3D 0; >=20 > + /* 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)); > +=20 > /* Actually create and show the dialog. */ > create_and_show_dialog (f, first_wv); >=20 > ! unbind_to (specpdl_count, Qnil); >=20 > /* Find the selected item, and its pane, to return > the proper value. */ >=20 >=20 >=20 > 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=3D-L/opt/local/lib' 'CPPFLAGS=3D-I/opt/local/include' = 'CFLAGS=3D-g'' >=20 > 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 >=20 > Major mode: Fundamental >=20 > 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 >=20 >=20 >=20