[Openmcl-devel] rest args are wrong in backtrace output

Gary Byers gb at clozure.com
Fri May 20 12:12:35 PDT 2005

On Fri, 20 May 2005, Timothy Moore wrote:

> I've been trying to get to the bottom of a problem I've been having with 
> openmcl and Slime. This is with the current non-bleeding edge CVS tree, but I 
> had the same problem in 0.14.2. Basically, in a couple of places code walks 
> the stack looking for arguments to a function. There is an assumption that 
> the order is required, optional, rest, and pairs of keyword and 
> key-supplied-p. Several functions do this, such as find-local-name in 
> lib/backtrace.lisp and frame-supplied-args in lib/backtracce-lds.lisp.

> However, this order doesn't seem to be valid anymore:

I believe that the stack-walking functions have always been wrong in
assuming that the &rest arg precedes &key args/supplied-p vars when
both &rest and &key are present.

When a function takes any of:
   - &rest
   - &key
   - &optional with any non-nil default value or any supplied-p var

the order in which things appear in the stack frame is:
1) required argument values
2) optional argument values
3) &key value/&key supplied-p pairs
4) &rest arg
5) &optional supplied-p vars.

If none of those 3 conditions hold (just required args and/or "simple"
&optionals), things are less canonical.

> This wouldn't be too annoying -- at least the names are right -- but 
> frame-supplied-args assumes that the rest argument is a list and cons stuff 
> on the front of it, when in fact that value can be anything at all. This 
> causes Slime to crash when it loops over the resulting improper list.

The crude listener backtrace (:b) calls FIND-LOCAL-NAME, and mis-labels
things when both &key and &rest are present.  I agree that that's at
least a minor annoyance, and it's fairly easy to fix.

I agree (perhaps for a different reason) that it's bad that SLIME is
calling random, buggy, undocumented, unsupported, and (otherwise)
unused random functions like FRAME-SUPPLIED-ARGS.  I'm not sure that
that can be undone (or that SLIME has a wholesome, robust, maintained
and maintainable alternative.)  If this (backwards &rest/&key) is
fixed, it's not clear that FRAME-SUPPLIED-ARGS suddenly becomes part
of a wholesome and maintainable API.

> For my education, where does the compiler lay out a function's stack?

Mostly in the functions PPC2-LAMBDA and PPC2-BIND-LAMBDA, both in 
"ccl:compiler;PPC;ppc2.lisp".  Especially in the complicated/
canonical case, most of the actual argument shuffling/&rest/&key
handling happens out-of-line.

> Tim
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel

More information about the Openmcl-devel mailing list