GNU bug report logs - #13543
24.2; [PATCH] (ert) "wrong-type-argument characterp" when assert fail on large (>28 bit) numbers

Previous Next

Package: emacs;

Reported by: Oleksandr Gavenko <gavenkoa <at> gmail.com>

Date: Thu, 24 Jan 2013 20:34:02 UTC

Severity: normal

Tags: patch

Found in version 24.2

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13543 in the body.
You can then email your comments to 13543 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13543; Package emacs. (Thu, 24 Jan 2013 20:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleksandr Gavenko <gavenkoa <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 24 Jan 2013 20:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2;
	[PATCH] (ert) "wrong-type-argument characterp" when assert fail on
	large (>28 bit) numbers
Date: Thu, 24 Jan 2013 22:32:35 +0200
[Message part 1 (text/plain, inline)]
In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-09 on trouble, modified by Debian

'should' from lisp/emacs-lisp/ert.el fail to create character from number, for
example evaluate one of these expressions:

  (should (equal #x1000000 1))
  (should (equal 1 -1))

Problem come from "?%c" in:

  (defun ert--explain-format-atom (x)
    "Format the atom X for `ert--explain-equal'."
    (typecase x
      (fixnum (list x (format "#x%x" x) (format "?%c" x)))
      (t x)))

Another problem from (format "?%c" x) is performance penalty when "x" is rare
character code (font library intensively scan for missing character glyph
among all system available fonts causing 5 second delay and 100% hard disk
usage).

I recommend remove formatting to character as amount of problems are larger
then amount of benefits.

I discover this issue when start write tests for low level binary parsing
library (ASN.1).

[Message part 2 (text/plain, inline)]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-12-19 13:01:16 +0000
+++ lisp/ChangeLog	2013-01-24 20:29:45 +0000
@@ -1,3 +1,10 @@
+2013-01-24  Oleksandr Gavenko  <gavenkoa <at> gmail.com>
+
+	* ert.el (ert--explain-format-atom): Delete formating into
+	character due to performance issue on attempts to find font glyph
+	for rare used character and impossibility handle negative or large
+	numbers.
+
 2012-12-19  Michael Albinus  <michael.albinus <at> gmx.de>
 
 	* net/tramp-sh.el (tramp-sh-handle-file-acl): Delete empty lines

=== modified file 'lisp/emacs-lisp/ert.el'
--- lisp/emacs-lisp/ert.el	2012-11-23 03:26:09 +0000
+++ lisp/emacs-lisp/ert.el	2013-01-24 20:21:48 +0000
@@ -568,7 +568,7 @@
 (defun ert--explain-format-atom (x)
   "Format the atom X for `ert--explain-equal'."
   (cl-typecase x
-    (fixnum (list x (format "#x%x" x) (format "?%c" x)))
+    (fixnum (list x (format "#x%x" x)))
     (t x)))
 
 (defun ert--explain-equal-rec (a b)

[Message part 3 (text/plain, inline)]
-- 
Best regards!

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13543; Package emacs. (Mon, 04 Feb 2013 07:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 13543 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Oleksandr Gavenko <gavenkoa <at> gmail.com>
Cc: 13543 <at> debbugs.gnu.org
Subject: Re: bug#13543: 24.2;
	[PATCH] (ert) "wrong-type-argument characterp" when assert fail on
	large (>28 bit) numbers
Date: Mon, 04 Feb 2013 02:49:05 -0500
Oleksandr Gavenko wrote:

> 'should' from lisp/emacs-lisp/ert.el fail to create character from
> number, for example evaluate one of these expressions:
>
>   (should (equal #x1000000 1))
>   (should (equal 1 -1))

I can see some usefulness to printing the character form for something
like

(should (equal ?a ?b))

so I installed this change:

***************
*** 568,574 ****
  (defun ert--explain-format-atom (x)
    "Format the atom X for `ert--explain-equal'."
    (cl-typecase x
!     (fixnum (list x (format "#x%x" x) (format "?%c" x)))
      (t x)))
  
  (defun ert--explain-equal-rec (a b)
--- 568,575 ----
  (defun ert--explain-format-atom (x)
    "Format the atom X for `ert--explain-equal'."
    (cl-typecase x
!     (character (list x (format "#x%x" x) (format "?%c" x)))
!     (fixnum (list x (format "#x%x" x)))
      (t x)))
  
  (defun ert--explain-equal-rec (a b)


 > Another problem from (format "?%c" x) is performance penalty when "x"
 > is rare character code (font library intensively scan for missing
 > character glyph among all system available fonts causing 5 second
 > delay and 100% hard disk usage).

This seems like a general issue rather than an ERT one.

> I recommend remove formatting to character as amount of problems are
> larger then amount of benefits.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13543; Package emacs. (Mon, 04 Feb 2013 15:35:02 GMT) Full text and rfc822 format available.

Message #11 received at 13543 <at> debbugs.gnu.org (full text, mbox):

From: Oleksandr Gavenko <gavenkoa <at> gmail.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 13543 <at> debbugs.gnu.org
Subject: Re: bug#13543: 24.2;
	[PATCH] (ert) "wrong-type-argument characterp" when assert fail on
	large (>28 bit) numbers
Date: Mon, 04 Feb 2013 17:33:43 +0200
On 2013-02-04, Glenn Morris wrote:

>> 'should' from lisp/emacs-lisp/ert.el fail to create character from
>> number, for example evaluate one of these expressions:
>>
>>   (should (equal #x1000000 1))
>>   (should (equal 1 -1))
>
> I can see some usefulness to printing the character form for something
> like
>
> (should (equal ?a ?b))
>
> so I installed this change:
>
> ***************
> *** 568,574 ****
>   (defun ert--explain-format-atom (x)
>     "Format the atom X for `ert--explain-equal'."
>     (cl-typecase x
> !     (fixnum (list x (format "#x%x" x) (format "?%c" x)))
>       (t x)))
>   
>   (defun ert--explain-equal-rec (a b)
> --- 568,575 ----
>   (defun ert--explain-format-atom (x)
>     "Format the atom X for `ert--explain-equal'."
>     (cl-typecase x
> !     (character (list x (format "#x%x" x) (format "?%c" x)))
> !     (fixnum (list x (format "#x%x" x)))
>       (t x)))
>   
>   (defun ert--explain-equal-rec (a b)
>
Your idea look good to me. I think about it but afraid inconsistent of output
(print 3 filed for character and 2 for fixnum). That is why I don't suggest
this solution...

One essential point is that if some test check fail all followed tests doesn't
executed due to this bug. So this must be fixed in any way...

-- 
Best regards!




bug marked as fixed in version 24.4, send any further explanations to 13543 <at> debbugs.gnu.org and Oleksandr Gavenko <gavenkoa <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 11 Jun 2013 23:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 10 Jul 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 314 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.