unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* wrong-type-argument charsetp unbound error in emacs-unicode-2 current
@ 2006-11-03 20:05 Bob Halley
  2006-11-04  5:01 ` James Cloos
  0 siblings, 1 reply; 5+ messages in thread
From: Bob Halley @ 2006-11-03 20:05 UTC (permalink / raw)


Up until a few days ago, I had no problem with running the head of the 
emacs-unicode-2 branch, but it is now failing.

If I start emacs and then kill some text, e.g. something simple like 
"foo^A^K" in *scratch*, then I get a  (wrong-type-argument charsetp 
unbound) error.  Emacs usually doesn't survive long after reporting that 
error either, typically dying with SIGSEGV after a few additional 
editing operations.

I set debug-on-error and the backtrace is:

Debugger entered--Lisp error: (wrong-type-argument charsetp unbound)
  ccl-execute-on-string([0 61 257 829 16 128 -1020 1 827 16 194 22 78 
82681 192 1019 21 128 22 1083 16 224 257 -5372 78 82681 192 1019 21 128 
22 1083 16 240 257 -8444 78 82681 192 1019 21 128 22 1083 16 248 257 
-11516 78 82681 ...] [0 0 0 0 0 0 0 0 0] "foo")
  string-utf-8-p("foo")
  xselect-convert-to-string(PRIMARY UTF8_STRING #("foo" 0 1 (fontified t 
auto-composed t) 1 2 (fontified t auto-composed t) 2 3 (fontified t 
auto-composed t)))

I didn't get any core from the SIGSEGV.

I can easily reproduce the problem, so let me know if you need any more 
info.

/Bob

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
  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
  0 siblings, 1 reply; 5+ messages in thread
From: James Cloos @ 2006-11-04  5:01 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> "Bob" == Bob Halley <halley@play-bow.org> writes:

Bob> Up until a few days ago, I had no problem with running the head
Bob> of the emacs-unicode-2 branch, but it is now failing.

Bob> If I start emacs and then kill some text, e.g. something simple
Bob> like "foo^A^K" in *scratch*, then I get a (wrong-type-argument
Bob> charsetp unbound) error.  Emacs usually doesn't survive long
Bob> after reporting that error either, typically dying with SIGSEGV
Bob> after a few additional editing operations.

I just gave it a try with a compile that is just a couple of hours
older than your post, and did not see the SEGV.

I use gentoo's ebuild for 23.0.0, and end up with this configure line:

./configure --prefix=/usr --host=i686-pc-linux-gnu \
 --mandir=/usr/share/man --infodir=/usr/share/info \
 --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib \
 --enable-debug --program-suffix=.emacs-23.0.0 --without-carbon \
 --with-x --with-xpm --with-toolkit-scroll-bars --enable-font-backend \
 --with-freetype --with-xft --with-jpeg --with-tiff --with-gif \
 --with-png --with-x-toolkit=athena --build=i686-pc-linux-gnu

Which toolkit do you use?  I've noticed that using gtk (as emacs'
toolkit) often leads to more bugs than the alternatives.....

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0xED7DAEA6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Bob Halley @ 2006-11-04 17:50 UTC (permalink / raw)
  Cc: emacs-devel

James Cloos wrote:
>
> Which toolkit do you use?  I've noticed that using gtk (as emacs'
> toolkit) often leads to more bugs than the alternatives.....
>   
I configured emacs with --prefix=/usr/local/emacs-23 --with-gtk 
--enable-font-backend.

I've found out a few more things:

The elisp error can be triggered by evaluating (utf-8-string-p "foo").

Reverting to version 1.20.2.7 of select.el makes the lisp error go away 
and emacs no longer segfaults.  The difference between 1.20.2.7 and 
1.20.2.8 is the addition of utf-8-string-p and its associated ccl program.

To me, the evidence so far points at a problem in the ccl code.  I also 
think it is likely that whatever is broken is also smashing memory, as 
emacs stopped segfaulting when I reverted select.el.

I'll keep poking around and see if I can learn anything else.

/Bob

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
  2006-11-04 17:50   ` Bob Halley
@ 2006-11-04 18:42     ` James Cloos
  2006-11-06  7:04     ` Bob Halley
  1 sibling, 0 replies; 5+ messages in thread
From: James Cloos @ 2006-11-04 18:42 UTC (permalink / raw)
  Cc: emacs-devel

>>>>> "Bob" == Bob Halley <halley@play-bow.org> writes:

Bob> The elisp error can be triggered by evaluating (utf-8-string-p "foo").

I presume you mean (string-utf-8-p "foo").  I do get either a SEGV (if
running in a shell with ulimit -c 0) or memory exhausted (if running
in a shell with ulimit -c unlimited) from that.  But your earlier
example apparently does not run that code path on my install.

The error is independent of --enable-font-backend.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0xED7DAEA6

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: wrong-type-argument charsetp unbound error in emacs-unicode-2 current
  2006-11-04 17:50   ` Bob Halley
  2006-11-04 18:42     ` James Cloos
@ 2006-11-06  7:04     ` Bob Halley
  1 sibling, 0 replies; 5+ messages in thread
From: Bob Halley @ 2006-11-06  7:04 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-06  7:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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).