backtrace ugliness when passing invalid number of arguments to cached gf
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Medium
|
Unassigned |
Bug Description
The following code
(defgeneric gf2 (x y)
(:method (x y)
(+ x y)))
(defun bar2 (z)
(gf2 z))
exhibits the following backtrace behaviour.
First we call GF2 cold:
CL-USER> (bar2 1)
; Evaluation aborted.
And we get a reasonably looking backtrace. A perfect backtrace would
include (BAR2 1) and (GF 1) -- the latter is probably optimized away
because it's a tailcall.
The function
#<STANDARD-
requires at least 2 arguments.
[Condition of type SB-INT:
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {B8DEFD9}>)
Backtrace:
0: (SB-PCL:
1: (SB-PCL:
2: (SB-INT:
Anyway, the problem is if we get GF2 into PCL caches:
CL-USER> (gf2 1 2)
3
CL-USER> (bar2 1)
; Evaluation aborted.
Now we get a very bad backtrace that does not only look bad, but
which is doubly bad because `v' in the debugger on the top frame
won't work, too. No fun to debug this.
invalid number of arguments: 1
[Condition of type SB-INT:
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [ABORT] Return to SLIME's top level.
2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {B8DEFD9}>)
Backtrace:
0: ((LAMBDA (SB-PCL::.ARG0. SB-PCL::.ARG1.)) 1)[:EXTERNAL]
1: (SB-INT:
Changed in sbcl: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
tags: | added: compiler debugger pcl |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
Fixing after freeze:
diff --git a/src/pcl/ methods. lisp b/src/pcl/ methods. lisp methods. lisp methods. lisp
(make- dfun-lambda- list nargs applyp)
(make- fast-method- call-lambda- list nargs applyp))))
(multiple- value-bind (cfunction constants)
,arglist
,@(unless function-p
` ((declare (ignore .pv. .next-method- call.)) ))
index c1e5fc4..efbd482 100644
--- a/src/pcl/
+++ b/src/pcl/
@@ -1414,7 +1414,7 @@
- (get-fun1 `(lambda
+ (get-fun1 `(named-lambda (gf-dispatch ,name)
gets us:
0: ((SB-PCL: :GF-DISPATCH GF2) 1) [external] SIMPLE- EVAL-IN- LEXENV (BAR2 1) #<NULL-LEXENV>)
1: (SB-INT:
2: (EVAL (BAR2 1))
In the first case GF2 isn't missing because