Opened 14 years ago

Closed 14 years ago

#79 closed defect (fixed)

Identically named gensymed coalesced into same object in fasl file

Reported by: trittweiler Owned by: ehuelsmann
Priority: major Milestone:
Component: compiler Version:
Keywords: Cc:
Parent Tickets:

Description

From: Erik Huelsmann
Date: Mon, Jan 11, 2010 at 11:40 PM
Subject: Re: [armedbear-devel] [Bug] Identically named gensymed
coalesced into same object in fasl file
To: "Tobias C. Rittweiler"

Hi Tobias,

Thanks for your report. This issue has long been in ABCL and it's not fixed yet.

I have known about this problem for a while, but was kind of hoping it
wouldn't show up in practice. I guess it did.

This is what happens: when reading, the fasl loader creates an
anonymous package in which it interns uninterned symbols. It "has" to
do that, because ABCL doesn't store references to the actual unique
objects everywhere; instead it stores the textual representation in
some places. These symbols get coalesced by use of the anonymous
package.

So, generally the system of coalescing is something inherent to this
idea. The idea is wrong enough for you to run into and get bitten by
it.

We'll have to come up with a better idea. Can you add the mail message
below to our issue tracker?

BTW: Did you happen to find this issue by accident? How did you find it?

Bye,

Erik.

On Mon, Jan 11, 2010 at 10:35 PM, Tobias C. Rittweiler wrote:

I'm currently running an old checkout ("0.17.0-dev"), so the issue may
have been fixed meanwhile.

### /tmp/foo.lisp

(eval-when (:load-toplevel :execute)

(let ((a '#:foo)

(b '#:foo))

(setf (fdefinition 'foo) (lambda () (values a b)))))

(eval-when (:load-toplevel :execute)

(format t "~&(multiple-value-call #'eq (foo)) => ~S~%"

(multiple-value-call #'eq (foo))))

###

CL-USER> (compile-file "/tmp/foo.lisp")

; Compiling /tmp/foo.lisp ...

; (LET (# #) ...)

; (FORMAT T ...)

; Compilation unit finished

;   The following functions were used but not defined:

;     FOO

; Wrote /tmp/foo.abcl (0.034 seconds)

#P"/tmp/foo.abcl"

NIL

NIL

That warning is bogus. There some work in this area so this bit may be
fixed already.

The actual issue of my mail is this one, though:

CL-USER> (load *)

(multiple-value-call #'eq (foo)) => T

T

As you can see, ABCL coalesces the two identical named gensyms into the
same object in the fasl file.

While 3.2.4.2.2 does specify that

Two apparently uninterned symbols S and C are similar if their names

are similar.

ABCL's behavior is still wrong because 3.2.4.1 says

If two literal objects appearing in the source code for a single file

processed with the file compiler are the [sic] identical, the

corresponding objects in the compiled code must also be the

identical. With the exception of symbols and packages, any two

literal objects in code being processed by the file compiler may be

coalesced if and only if they are similar; if they are either both

symbols or both packages, they may only be coalesced if and only if

they are identical.

-T.

Change History (4)

comment:1 Changed 14 years ago by ehuelsmann

What about changing the scheme from the current "anonymous package" to the following:

  • The file-compiler collects all uninterned symbols during compilation
  • The symbols get associated with numbers
  • The file-compiler puts the symbols in an alist or array which is stored in a special variable at the beginning of the fasl
  • The compiled functions refer to the symbol by integer while loading

This way, it's an option to create 2 different uninterned symbols by the same name:

(setq *fasl-uninterned-symbols*

#(#:foo #:foo))

comment:2 Changed 14 years ago by ehuelsmann

Component: CLOScompiler
Owner: changed from somebody to ehuelsmann

comment:3 Changed 14 years ago by ehuelsmann

(In [12649]) Re #79: Add *FASL-UNINTERNED-SYMBOLS* variable to Load.java and save its value
in AutoloadedFunctionProxy?, just like *FASL-ANONYMOUS-PACKAGE*.

comment:4 Changed 14 years ago by ehuelsmann

Resolution: fixed
Status: newclosed

(In [12650]) Fix #79: Equally named -but different- uninterned symbols coalesced into
one in FASLs.

This commit removes the *FASL-ANONYMOUS-PACKAGE*: it's replaced by
*FASL-UNINTERNED-SYMBOLS* and a dispatch macro function which resolves
symbols by index instead of by name.

Note: See TracTickets for help on using tickets.