unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: GC garbles menu items
Date: Tue, 20 Dec 2005 23:54:07 +0200	[thread overview]
Message-ID: <87psnrmwm8.fsf@jurta.org> (raw)
In-Reply-To: <E1EnlyG-0000wF-Fw@fencepost.gnu.org> (Richard M. Stallman's message of "Sat, 17 Dec 2005 19:00:12 -0500")

>     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/

  reply	other threads:[~2005-12-20 21:54 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m3sltjuvd6.fsf@czkmt.remus.dti.ne.jp>
2005-11-27  3:28 ` tooltip can be displayed outside the screen Richard M. Stallman
2005-11-27  4:55   ` Tetsuo Tsukamoto
2005-11-27 22:34     ` Richard M. Stallman
2005-12-02 14:58       ` Jan D.
2005-12-02 18:33         ` Eli Zaretskii
2005-12-02 21:04           ` Juri Linkov
2005-12-03 14:21           ` Jan Djärv
2005-12-06  0:52             ` Juri Linkov
2005-12-12 10:25               ` Jan D.
2005-12-14  7:54                 ` Juri Linkov
2005-12-14 21:01                   ` Jan Djärv
2005-12-15  9:28                     ` Juri Linkov
2005-12-16  1:52                       ` Richard M. Stallman
2005-12-16  9:03                         ` Juri Linkov
2005-12-17  1:04                           ` Richard M. Stallman
2005-12-17 10:48                             ` GC garbles menu items (was: tooltip can be displayed outside the screen) Juri Linkov
2005-12-18  0:00                               ` Richard M. Stallman
2005-12-20 21:54                                 ` Juri Linkov [this message]
2005-12-22  5:47                                   ` GC garbles menu items Richard M. Stallman
2005-12-22 20:48                                     ` Juri Linkov

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87psnrmwm8.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).