all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bob Halley <halley@play-bow.org>
Subject: Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
Date: Sun, 05 Nov 2006 23:04:07 -0800	[thread overview]
Message-ID: <454EDE67.5040608@play-bow.org> (raw)
In-Reply-To: <454CD2D5.2020609@play-bow.org>

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

I ran emacs under gdb, stepping through Fccl_execute_on_string.  When 
doing the "is this a utf-8 string" test on "foo", I caught it doing a 
massive character copy of millions of characters.  This happened because 
ccl.produced was a large number (around 5 million).

I then went looking for a reason for ccl.produced to be so wrong.  The 
CCL program in question has a "buffer magnification" of zero, which 
means "produce no bytes".  In this case the current destination pointer, 
dst, is set to NULL.  A NULL dst causes the calculation of ccl->produced 
just after the ccl_finish tag in ccl_driver() to be wrong, because the 
code does

ccl->produced = dst - destination

I changed this code (patch attached) so that it set ccl->produced to 
zero if dst was NULL.  With this change, both the type error and the 
segfault no longer happen.  (The type error is fixed because we're no 
longer reading random memory and treating it as encoded characters.)

Regards,

/Bob


[-- Attachment #2: ccl.patch --]
[-- Type: text/x-patch, Size: 586 bytes --]

Index: src/ccl.c
===================================================================
RCS file: /sources/emacs/emacs/src/ccl.c,v
retrieving revision 1.82.4.14
diff -u -r1.82.4.14 ccl.c
--- src/ccl.c	3 Mar 2006 05:13:48 -0000	1.82.4.14
+++ src/ccl.c	6 Nov 2006 06:50:23 -0000
@@ -1782,7 +1782,10 @@
   ccl->stack_idx = stack_idx;
   ccl->prog = ccl_prog;
   ccl->consumed = src - source;
-  ccl->produced = dst - destination;
+  if (dst != NULL)
+	  ccl->produced = dst - destination;
+  else
+	  ccl->produced = 0;
 }
 
 /* Resolve symbols in the specified CCL code (Lisp vector).  This

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

      parent reply	other threads:[~2006-11-06  7:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-03 20:05 wrong-type-argument charsetp unbound error in emacs-unicode-2 current Bob Halley
2006-11-04  5:01 ` James Cloos
2006-11-04 17:50   ` Bob Halley
2006-11-04 18:42     ` James Cloos
2006-11-06  7:04     ` Bob Halley [this message]

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=454EDE67.5040608@play-bow.org \
    --to=halley@play-bow.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 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.