Hi Erik,
ABCL appears to remove a function definition that it incorrectly thinks is unused. I've attached abcl-bug.lisp. Here is a transcript:
---- ABCL (fails)
VibhuMondrasMBP:Desktop vibhu$ abcl.sh Armed Bear Common Lisp 1.3.1 Java 1.8.0_11 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.394 seconds. Startup completed in 1.8 seconds. Loading /Users/vibhu/.abclrc completed in 11.668 seconds. Type ":help" for a list of available commands. CL-USER(1): (load "abcl-bug") ; Note: deleting unused local function LABELS =G T CL-USER(2): (sample2 1) #<THREAD "interpreter" {4F4C3489}>: Debugger invoked on condition of type UNDEFINED-FUNCTION The function SAMPLE2 is undefined. Restarts: 0: CONTINUE Try again. 1: USE-VALUE Specify a function to call instead. 2: RETURN-VALUE Return one or more values from the call to SAMPLE2. 3: TOP-LEVEL Return to top level. [1] CL-USER(3):
---- CLISP (works)
VibhuMondrasMBP:Desktop vibhu$ clisp ;; Loading file /Users/vibhu/.clisprc ... ;; Loading file /Users/vibhu/quicklisp/setup.lisp ... ;; Loading file /Users/vibhu/quicklisp/ASDF.lisp ... ;; Loaded file /Users/vibhu/quicklisp/ASDF.lisp ;; Loaded file /Users/vibhu/quicklisp/setup.lisp ;; Loaded file /Users/vibhu/.clisprc [1]> (load "abcl-bug") ;; Loading file /Users/vibhu/Desktop/abcl-bug.lisp ... ;; Loaded file /Users/vibhu/Desktop/abcl-bug.lisp T [2]> (bug) 1 [3]> (load "tco2") ;; Loading file /Users/vibhu/Desktop/tco2.lisp ... ;; Loaded file /Users/vibhu/Desktop/tco2.lisp T [4]> (sample2 1) 1
On 4/4/15 18:28, Erik Huelsmann wrote:
[…]
The copy of the bug code you sent me got garbled as follows:
(defun =sample2 (n) (macrolet ((f (result x) `(list 'more (lambda () (=f ,result ,x)))) (g (result x) `(list 'more (lambda () (=g ,result ,x))))) (labels ((=f (result x) (if (zerop x) result (g (1+ result) (1- x)))) (=g (result x) (f result x))) (f 0 n))))
I assume that one is supposed to remove all the #= characters?
Hi Mark,
On Sun, Apr 5, 2015 at 11:13 AM, Mark Evenson evenson@panix.com wrote:
On 4/4/15 18:28, Erik Huelsmann wrote:
[…]
The copy of the bug code you sent me got garbled as follows:
(defun =sample2 (n) (macrolet ((f (result x) `(list 'more (lambda () (=f ,result ,x)))) (g (result x) `(list 'more (lambda () (=g ,result ,x))))) (labels ((=f (result x) (if (zerop x) result (g (1+ result) (1- x)))) (=g (result x) (f result x))) (f 0 n))))
I assume that one is supposed to remove all the #= characters?
It's exactly the code that was sent to me. I think the point is that the macrolet conceils the fact that the "=g" function is being called through the "g" macro and that ABCL incorrectly handles the situation as dead code.
Regards,
Hi,
On Sun, Apr 5, 2015 at 2:14 PM, Mark Evenson evenson@panix.com wrote:
But the example shows SAMPLE2 being executed not =SAMPLE2.
Ah. right. that's an error. I can see the error regarding dead code elimination in precompile.lisp:precompile-flet/labels. Working on a fix right now.
Regards,
Erik.
Tersely pecked on a Nexus 5 On Apr 5, 2015 2:09 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi Mark,
On Sun, Apr 5, 2015 at 11:13 AM, Mark Evenson evenson@panix.com wrote:
On 4/4/15 18:28, Erik Huelsmann wrote:
[…]
The copy of the bug code you sent me got garbled as follows:
(defun =sample2 (n) (macrolet ((f (result x) `(list 'more (lambda () (=f ,result ,x)))) (g (result x) `(list 'more (lambda () (=g ,result ,x))))) (labels ((=f (result x) (if (zerop x) result (g (1+ result) (1- x)))) (=g (result x) (f result x))) (f 0 n))))
I assume that one is supposed to remove all the #= characters?
It's exactly the code that was sent to me. I think the point is that the macrolet conceils the fact that the "=g" function is being called through the "g" macro and that ABCL incorrectly handles the situation as dead code.
Regards,
-- Bye,
Erik.
http://efficito.com -- Hosted accounting and ERP. Robust and Flexible. No vendor lock-in.
Hi Vibhu, Mark,
http://abcl.org/trac/changeset/14754 fixes the problem reported.
Thanks for reporting!
Regards,
Erik.
On Sun, Apr 5, 2015 at 3:06 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi,
On Sun, Apr 5, 2015 at 2:14 PM, Mark Evenson evenson@panix.com wrote:
But the example shows SAMPLE2 being executed not =SAMPLE2.
Ah. right. that's an error. I can see the error regarding dead code elimination in precompile.lisp:precompile-flet/labels. Working on a fix right now.
Regards,
Erik.
Tersely pecked on a Nexus 5 On Apr 5, 2015 2:09 PM, Erik Huelsmann ehuels@gmail.com wrote:
Hi Mark,
On Sun, Apr 5, 2015 at 11:13 AM, Mark Evenson evenson@panix.com wrote:
On 4/4/15 18:28, Erik Huelsmann wrote:
[…]
The copy of the bug code you sent me got garbled as follows:
(defun =sample2 (n) (macrolet ((f (result x) `(list 'more (lambda () (=f ,result ,x)))) (g (result x) `(list 'more (lambda () (=g ,result ,x))))) (labels ((=f (result x) (if (zerop x) result (g (1+ result) (1- x)))) (=g (result x) (f result x))) (f 0 n))))
I assume that one is supposed to remove all the #= characters?
It's exactly the code that was sent to me. I think the point is that the macrolet conceils the fact that the "=g" function is being called through the "g" macro and that ABCL incorrectly handles the situation as dead code.
Regards,
-- Bye,
Erik.
http://efficito.com -- Hosted accounting and ERP. Robust and Flexible. No vendor lock-in.
-- Bye,
Erik.
http://efficito.com -- Hosted accounting and ERP. Robust and Flexible. No vendor lock-in.
Awesome. Confirmed, fixed.
Sorry about the incomplete bug report, Mark. But you figured out the problem and diagnosed it anyway.
What I missed was submitting the driver function, sample2:
(defun sample2 (n) (do ((x (=sample2 n) (funcall (cadr x)))) ((not (and (consp x) (eq (car x) 'more))) x)))
---- Here is a transcript showing the bug manifesting in 1.3.1 but fixed in the SVN snapshot now. (1 is the correct expected return value of calling (sample2 1)).
VibhuMondrasMBP:t vibhu$ cat abcl-bug.lisp (defun =sample2 (n) (macrolet ((f (result x) `(list 'more (lambda () (=f ,result ,x)))) (g (result x) `(list 'more (lambda () (=g ,result ,x))))) (labels ((=f (result x) (if (zerop x) result (g (1+ result) (1- x)))) (=g (result x) (f result x))) (f 0 n)))) (defun sample2 (n) (do ((x (=sample2 n) (funcall (cadr x)))) ((not (and (consp x) (eq (car x) 'more))) x)))
VibhuMondrasMBP:t vibhu$ abcl.sh Armed Bear Common Lisp 1.3.1 Java 1.8.0_11 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.471 seconds. Startup completed in 2.397 seconds. Loading /Users/vibhu/.abclrc completed in 14.64 seconds. Type ":help" for a list of available commands. CL-USER(1): (load "abcl-bug") ; Note: deleting unused local function LABELS =G T CL-USER(2): (sample2 1) #<THREAD "interpreter" {5EBBB15C}>: Debugger invoked on condition of type UNDEFINED-FUNCTION The function =G is undefined. Restarts: 0: CONTINUE Try again. 1: USE-VALUE Specify a function to call instead. 2: RETURN-VALUE Return one or more values from the call to =G. 3: TOP-LEVEL Return to top level. [1] CL-USER(3):
vibhu:~/abcl$ java -jar dist/abcl2.jar Armed Bear Common Lisp 1.4.0-dev-svn-svn- The path '.' appears to be part of a Subversion 1.7 or greater Java 1.6.0_07 Sun Microsystems Inc. Java HotSpot(TM) Client VM Low-level initialization completed in 0.558 seconds. Startup completed in 3.288 seconds. Type ":help" for a list of available commands. CL-USER(1): (load "abcl-bug") T CL-USER(2): (sample2 1) 1 CL-USER(3):
armedbear-devel@common-lisp.net