From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: GC garbles menu items Date: Tue, 20 Dec 2005 23:54:07 +0200 Organization: JURTA Message-ID: <87psnrmwm8.fsf@jurta.org> References: <4390611E.3040500@swipnet.se> <4391A9CE.6090706@swipnet.se> <87acffdnrg.fsf@jurta.org> <439D501F.8060609@swipnet.se> <87pso1bdrb.fsf@jurta.org> <43A08825.8070704@swipnet.se> <87k6e6myqw.fsf@jurta.org> <873bkte58s.fsf@jurta.org> <87ek4cngkz.fsf_-_@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1135116275 29241 80.91.229.2 (20 Dec 2005 22:04:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 20 Dec 2005 22:04:35 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 20 23:04:34 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EopXT-0004HU-9o for ged-emacs-devel@m.gmane.org; Tue, 20 Dec 2005 23:00:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EopYN-0003xV-PW for ged-emacs-devel@m.gmane.org; Tue, 20 Dec 2005 17:01:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EopVz-0003GJ-3x for emacs-devel@gnu.org; Tue, 20 Dec 2005 16:59:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EopVx-0003FR-5j for emacs-devel@gnu.org; Tue, 20 Dec 2005 16:59:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EopVw-0003FK-W5 for emacs-devel@gnu.org; Tue, 20 Dec 2005 16:59:21 -0500 Original-Received: from [194.126.101.98] (helo=mail.neti.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EopYx-0004ep-4d; Tue, 20 Dec 2005 17:02:27 -0500 Original-Received: from mail.neti.ee (80-235-32-55-dsl.mus.estpak.ee [80.235.32.55]) by Relayhost1.neti.ee (Postfix) with ESMTP id E94511A85; Tue, 20 Dec 2005 23:58:29 +0200 (EET) Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Sat, 17 Dec 2005 19:00:12 -0500") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-2.2.1 (20041222) (Debian) at neti.ee X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:48114 Archived-At: > I can reproduce this bug only on non-toolkit builds. > > Aha, now I see. The non-toolkit definition of xmenu_show copies the > addresses of string text directly into the non-toolkit menu data. > When GC happens, it relocates the strings and garbles the text. Is it possible to prevent relocation of the strings in GC for the time while the menu is up? > Could you rewrite that code to copy the strings when making the menus, > and free the copies at the end? I think it's safer not to change memory allocation code in non-toolkit XMenu now just before the release. I believe it is possible to solve this problem by preventing string relocation the same way as it is done for menu items where keyboard equivalents are displayed in the same menu item. Such menu items are constructed by the following code in xmenu_show (and GC doesn't corrupt these menu items): #ifdef C_ALLOCA Lisp_Object spacer; spacer = Fmake_string (make_number (gap), make_number (' ')); item_name = concat2 (item_name, spacer); item_name = concat2 (item_name, descrip); item_data = SDATA (item_name); #else /* if alloca is fast, use that to make the space, to reduce gc needs. */ item_data = (unsigned char *) alloca (maxwidth + SBYTES (descrip) + 1); bcopy (SDATA (item_name), item_data, SBYTES (item_name)); for (j = SCHARS (item_name); j < maxwidth; j++) item_data[j] = ' '; bcopy (SDATA (descrip), item_data + j, SBYTES (descrip)); item_data[j + SBYTES (descrip)] = 0; #endif -- Juri Linkov http://www.jurta.org/emacs/