Opened 3 years ago

Last modified 3 years ago

#1397 new defect

Setting certain character attributes for non-ascii characters causes IDE crash

Reported by: rongarret Owned by:
Priority: normal Milestone: Cocoa IDE v?
Component: IDE Version: trunk
Keywords: Cc:


Executing the following two commands:

(setf (hi::character-attribute :lisp-syntax (code-char 256)) :open-paren)
(setf (hi::character-attribute :lisp-syntax (code-char 256)) :constituent)

causes the IDE to crash, with the following message in the altconsole:

> Error: The value :NEWLINE is not of the expected type (MEMBER :CLOSE-PAREN :OPEN-PAREN).
> While executing: HEMLOCK::COMPUTE-UNMATCHED-PARENS-COLORING-IN-REGION, in process Initial(0).

Note that:

  1. To reproduce the problem you have to enter these command separately to allow the IDE to print the return value from the first command. If you execute both commands in one transaction (e.g. within a PROGN) the problem does not occur.
  1. In between executing these two commands (i.e. while the character attribute is set to :open-paren), everything works normally, except that all capital "A" characters in the listener are printed in red. This is more of an annoyance than a problem. I mention it only because it's really weird, and might provide a clue as to what the fleep is going on.
  1. (hi::character-attribute :lisp-syntax (code-char 256)) is :constituent when CCL starts, so these two commands should be a no-op.
  1. This is reproducible (AFAICT) for any code-char >256
  1. If you set paren balancing for characters>255 it actually works. For example:
(setf (hi::character-attribute :lisp-syntax #\«) :open-paren)
(setf (hi::character-attribute :lisp-syntax #\») :close-paren)

Will allow you to balance European-style quotes. It is only when you try to undo this that the IDE crashes. (And in the meantime you have red A's.)

Change History (5)

comment:1 Changed 3 years ago by rongarret

  • Component changed from other to IDE

comment:2 Changed 3 years ago by rongarret

Well, there's yer problem right there:

;;; This has the effect of treating all characters with code > 255
;;; as if they were #\u+00ff.  Not quite right, but better than
;;; flying off the end.
(defmacro syntax-char-code (char)
  (let* ((code (gensym)))
    `(let* ((,code (char-code ,char)))
      (declare (type (mod #x110000) ,code))
      (if (< ,code 256)
        (char-code #\A)))))

To say that this is "not quite right" is putting it rather mildly :-)

comment:3 Changed 3 years ago by rongarret

The following patch seems to fix the problem despite the fact that it seems to me that more extensive surgery ought to be required:

Index: cocoa-ide/hemlock/src/charmacs.lisp
--- cocoa-ide/hemlock/src/charmacs.lisp	(revision 16804)
+++ cocoa-ide/hemlock/src/charmacs.lisp	(working copy)
@@ -43,7 +43,7 @@
       (declare (type (mod #x110000) ,code))
       (if (< ,code 256)
-        (char-code #\A)))))
+        255))))

comment:4 Changed 3 years ago by rongarret

But really it should be:

(defun syntax-char-code (char)
  (min 255 (char-code char)))

comment:5 Changed 3 years ago by rongarret

Oh foo, it turns out that doesn't work. «» have char-codes <255. You have to use e.g. “” to reproduce the problem.

It's a bummer that you can't delete comments on a ticket. I should probably delete this whole ticket and re-submit it. :-(

Note: See TracTickets for help on using tickets.