From unknown Sat Aug 16 19:20:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory Resent-From: YAMAMOTO Mitsuharu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Oct 2011 04:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9830 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 9830@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13192582248210 (code B ref -1); Sat, 22 Oct 2011 04:38:01 +0000 Received: (at submit) by debbugs.gnu.org; 22 Oct 2011 04:37:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTKR-00028N-VA for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:37:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTKP-00027t-1d for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:37:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHTJ2-0005RZ-7l for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:35:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTJ2-0005RV-5B for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:35:36 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTJ0-0004hT-NV for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHTIz-0005R4-Eh for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:34 -0400 Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:49871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTIy-0005QW-Nr for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:33 -0400 Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 60710C055D for ; Sat, 22 Oct 2011 13:35:27 +0900 (JST) Date: Sat, 22 Oct 2011 13:35:27 +0900 Message-ID: From: YAMAMOTO Mitsuharu User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?UTF-8?Q?Shij=C5=8D?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) Organization: Faculty of Science, Chiba University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: NetBSD 3.0 (DF) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.8 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) 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. 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 From unknown Sat Aug 16 19:20:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory 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: To: YAMAMOTO Mitsuharu Cc: 9830@debbugs.gnu.org Received: via spool by 9830-submit@debbugs.gnu.org id=B9830.13199966324604 (code B ref 9830); Sun, 30 Oct 2011 17:44:01 +0000 Received: (at 9830) by debbugs.gnu.org; 30 Oct 2011 17:43:52 +0000 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 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 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= Received: by 10.204.130.208 with SMTP id u16mr8247170bks.47.1319996501237; Sun, 30 Oct 2011 10:41:41 -0700 (PDT) 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) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Jan =?UTF-8?Q?Dj=C3=A4rv?= In-Reply-To: Date: Sun, 30 Oct 2011 18:41:40 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> References: X-Mailer: Apple Mail (2.1251.1) X-Spam-Score: -3.0 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) 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 From unknown Sat Aug 16 19:20:03 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: YAMAMOTO Mitsuharu Subject: bug#9830: closed (Re: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory) Message-ID: References: X-Gnu-PR-Message: they-closed 9830 X-Gnu-PR-Package: emacs Reply-To: 9830@debbugs.gnu.org Date: Mon, 31 Oct 2011 03:24:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1320031442-22456-1" This is a multi-part message in MIME format... ------------=_1320031442-22456-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 9830@debbugs.gnu.org. --=20 9830: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D9830 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1320031442-22456-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 9830-done) by debbugs.gnu.org; 31 Oct 2011 03:23:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKiTC-0005pW-S1 for submit@debbugs.gnu.org; Sun, 30 Oct 2011 23:23:31 -0400 Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RKiT9-0005pM-3X for 9830-done@debbugs.gnu.org; Sun, 30 Oct 2011 23:23:28 -0400 Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 7E3C2C0560 for <9830-done@debbugs.gnu.org>; Mon, 31 Oct 2011 12:21:14 +0900 (JST) Date: Mon, 31 Oct 2011 12:21:14 +0900 Message-ID: From: YAMAMOTO Mitsuharu To: 9830-done@debbugs.gnu.org Subject: Re: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory In-Reply-To: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> References: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) Organization: Faculty of Science, Chiba University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9830-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) >>>>> On Sun, 30 Oct 2011 18:41:40 +0100, Jan Dj=E4rv = said: >> 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? Done. > As for xmenu_show, is there a case where a menu can be interrupted > like this? Yes. For example, (with-timeout (3 'default) (x-popup-menu t '("Title" ("foo" "nonselectable")))) Actually, y-or-n-p-with-timeout is implemented using with-timeout. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp ------------=_1320031442-22456-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 22 Oct 2011 04:37:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTKR-00028N-VA for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:37:04 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RHTKP-00027t-1d for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:37:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHTJ2-0005RZ-7l for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:35:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:33983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTJ2-0005RV-5B for submit@debbugs.gnu.org; Sat, 22 Oct 2011 00:35:36 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTJ0-0004hT-NV for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RHTIz-0005R4-Eh for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:34 -0400 Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:49871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RHTIy-0005QW-Nr for bug-gnu-emacs@gnu.org; Sat, 22 Oct 2011 00:35:33 -0400 Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 60710C055D for ; Sat, 22 Oct 2011 13:35:27 +0900 (JST) Date: Sat, 22 Oct 2011 13:35:27 +0900 Message-ID: From: YAMAMOTO Mitsuharu To: bug-gnu-emacs@gnu.org Subject: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?ISO-8859-4?Q?Shij=F2?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) Organization: Faculty of Science, Chiba University MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-detected-operating-system: by eggs.gnu.org: NetBSD 3.0 (DF) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.8 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.8 (----) 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. 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 ------------=_1320031442-22456-1-- From unknown Sat Aug 16 19:20:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory 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, 06 Nov 2011 15:58:02 +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: To: YAMAMOTO Mitsuharu Cc: 9830@debbugs.gnu.org Received: via spool by 9830-submit@debbugs.gnu.org id=B9830.132059506626902 (code B ref 9830); Sun, 06 Nov 2011 15:58:02 +0000 Received: (at 9830) by debbugs.gnu.org; 6 Nov 2011 15:57:46 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RN56P-0006zr-M4 for submit@debbugs.gnu.org; Sun, 06 Nov 2011 10:57:45 -0500 Received: from mailout.melmac.se ([62.20.26.67]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RN56M-0006zi-Tt for 9830@debbugs.gnu.org; Sun, 06 Nov 2011 10:57:43 -0500 Received: from mail01.melmac.se (mail01.melmac.se [62.20.26.80]) by mailout.melmac.se (Postfix) with ESMTP id 1FDD52CC79 for <9830@debbugs.gnu.org>; Sun, 6 Nov 2011 16:54:53 +0100 (CET) Received: (qmail 4310 invoked by uid 89); 6 Nov 2011 15:54:53 -0000 Received: from h-46-59-42-18.na.cust.bahnhof.se (HELO coolsville.localdomain) (boel.djarv@bdtv.se@46.59.42.18) by mail01.melmac.se with ESMTPA; 6 Nov 2011 15:54:53 -0000 Received: from [172.20.199.13] (zeplin [172.20.199.13]) by coolsville.localdomain (Postfix) with ESMTPSA id 8F9957FA058; Sun, 6 Nov 2011 16:54:52 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Jan =?UTF-8?Q?Dj=C3=A4rv?= In-Reply-To: Date: Sun, 6 Nov 2011 16:54:52 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> X-Mailer: Apple Mail (2.1251.1) X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Hello. 31 okt 2011 kl. 04:21 skrev YAMAMOTO Mitsuharu: >>>>>> On Sun, 30 Oct 2011 18:41:40 +0100, Jan Dj=E4rv = said: >=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 >=20 >> You are correct. Can you install the patch? >=20 > Done. I see you checked in this in the emacs-23 tree. Is that still merged to = the trunk? >=20 >> As for xmenu_show, is there a case where a menu can be interrupted >> like this? >=20 > Yes. For example, >=20 > (with-timeout (3 'default) > (x-popup-menu t '("Title" ("foo" "nonselectable")))) >=20 > Actually, y-or-n-p-with-timeout is implemented using with-timeout. I'm waiting for your fix to show up in the trunk before fixing this. I = don't think it makes sense to use the emacs-23 tree anymore. Jan D. From unknown Sat Aug 16 19:20:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9830: 23.3.50; y-or-n-p-with-timeout with GUI leaks memory Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Nov 2011 23:42:02 +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: To: Jan =?UTF-8?Q?Dj=C3=A4rv?= Cc: 9830@debbugs.gnu.org, YAMAMOTO Mitsuharu Received: via spool by 9830-submit@debbugs.gnu.org id=B9830.132062292110278 (code B ref 9830); Sun, 06 Nov 2011 23:42:02 +0000 Received: (at 9830) by debbugs.gnu.org; 6 Nov 2011 23:42:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNCLf-0002fi-Kv for submit@debbugs.gnu.org; Sun, 06 Nov 2011 18:42:00 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RNCLb-0002fZ-Qz for 9830@debbugs.gnu.org; Sun, 06 Nov 2011 18:41:56 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RNCIq-0000HM-TV; Sun, 06 Nov 2011 18:39:04 -0500 From: Glenn Morris References: <6C4E53F1-E6F7-40AF-A28B-8A169EB28B0C@swipnet.se> X-Spook: president kilderkin industrial espionage hackers X-Ran: h$mkQMF5!9-=]K4"@%\l*E}JMq`C.&R?-!4v*nw(|}+|1Y,U;#Em7WvTYSt{TiMxv9tjc; X-Hue: green X-Attribution: GM Date: Sun, 06 Nov 2011 18:39:04 -0500 In-Reply-To: ("Jan =?UTF-8?Q?Dj=C3=A4rv?="'s message of "Sun, 6 Nov 2011 16:54:52 +0100") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) Jan Dj=C3=A4rv wrote: > I'm waiting for your fix to show up in the trunk before fixing this. I merged it. > I don't think it makes sense to use the emacs-23 tree anymore. I agree (in fact I think this point was reached months ago).