* Re: subtle byte-compiler bug
@ 2004-01-07 15:07 David PONCE
2004-01-08 0:19 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: David PONCE @ 2004-01-07 15:07 UTC (permalink / raw)
Cc: emacs-devel
Hi,
Oliver Scholz wrote:
> David Ponce (CCed here) suggested that this is a bug in the
> byte-compiler. He also noted that this bug is not in 21.3.
[...]
I finally got a little time to investigate on that problem and
discovered that the bug is not in the byte-compiler but in the
`prin1' primitive.
Sometimes `prin1' print incorrect uninterned symbol references,
that can result in writing invalid byte-compiled code.
Here is a small example of code that illustrates the bug:
(let* ((n 512)
(print-escape-newlines t)
(print-length nil)
(print-level nil)
(print-quoted t)
(print-gensym t)
(v (make-vector n (list 1 2 3)))
(tmp1 (make-symbol "defconst-tmp-var"))
(tmp2 (make-symbol "defconst-tmp-var"))
)
(aset v 3 `(lambda (,tmp1) (defconst v1 ,tmp1)))
(aset v 8 `(lambda (,tmp2) (defconst v2 ,tmp2)))
(prin1 v))
When I eval it in the *scratch* buffer, `prin1' print something like
the following, which is obviously incorrect :-(
[(1 2 3) (1 2 3) (1 2 3)
(lambda (#:defconst-tmp-var) (defconst v1 #:defconst-tmp-var))
(1 2 3) (1 2 3) (1 2 3) (1 2 3)
(lambda (#:defconst-tmp-var) (defconst v2 #:defconst-tmp-var))
(1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) ...]
However, If I simply change (n 512) to (n 511) in the `let'
expression, the printed result is then correct:
[(1 2 3) (1 2 3) (1 2 3)
(lambda (#1=#:defconst-tmp-var) (defconst v1 #1#))
(1 2 3) (1 2 3) (1 2 3) (1 2 3)
(lambda (#2=#:defconst-tmp-var) (defconst v2 #2#))
(1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) (1 2 3) ...]
I am running:
GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, GTK+ Version 2.2.4)
of 2004-01-07
configured using `configure '--prefix=/home/ponce' '--with-x-toolkit=gtk''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8
default-enable-multibyte-characters: t
Hope this will help.
Sincerely,
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: subtle byte-compiler bug
2004-01-07 15:07 subtle byte-compiler bug David PONCE
@ 2004-01-08 0:19 ` Andreas Schwab
2004-01-08 13:38 ` Richard Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-01-08 0:19 UTC (permalink / raw)
Cc: emacs-pretest-bug, emacs-devel
David PONCE <david.ponce@wanadoo.fr> writes:
> I finally got a little time to investigate on that problem and
> discovered that the bug is not in the byte-compiler but in the
> `prin1' primitive.
>
> Sometimes `prin1' print incorrect uninterned symbol references,
> that can result in writing invalid byte-compiled code.
Thanks for the testcase. I have installed this change to fix the bug:
* print.c (print_preprocess) <case Lisp_Vectorlike>: Only mask
size if PSEUDOVECTOR_FLAG is set.
Index: print.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/print.c,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -a -p -a -u -p -r1.196 -r1.197
--- print.c 31 Dec 2003 00:24:28 -0000 1.196
+++ print.c 8 Jan 2004 00:15:52 -0000 1.197
@@ -1342,7 +1342,9 @@ print_preprocess (obj)
goto loop;
case Lisp_Vectorlike:
- size = XVECTOR (obj)->size & PSEUDOVECTOR_SIZE_MASK;
+ size = XVECTOR (obj)->size;
+ if (size & PSEUDOVECTOR_FLAG)
+ size &= PSEUDOVECTOR_SIZE_MASK;
for (i = 0; i < size; i++)
print_preprocess (XVECTOR (obj)->contents[i]);
break;
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: subtle byte-compiler bug
@ 2004-01-08 8:12 David PONCE
0 siblings, 0 replies; 4+ messages in thread
From: David PONCE @ 2004-01-08 8:12 UTC (permalink / raw)
Cc: emacs-pretest-bug, emacs-devel
Hi Andreas,
> Thanks for the testcase. I have installed this change to fix the bug:
>
> * print.c (print_preprocess) <case Lisp_Vectorlike>: Only mask
> size if PSEUDOVECTOR_FLAG is set.
It works like a charm now :-)
Thanks!
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: subtle byte-compiler bug
2004-01-08 0:19 ` Andreas Schwab
@ 2004-01-08 13:38 ` Richard Stallman
0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2004-01-08 13:38 UTC (permalink / raw)
Cc: emacs-pretest-bug, david.ponce, emacs-devel
Thanks for fixing this, and thanks very much David for tracking it down.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-08 13:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-07 15:07 subtle byte-compiler bug David PONCE
2004-01-08 0:19 ` Andreas Schwab
2004-01-08 13:38 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2004-01-08 8:12 David PONCE
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).