Closed HiroIshida closed 5 years ago
Apparently we are having a problem with euslisp handling long recursive functions (event being tailed ones)
(defun test (l)
(let ((i 0))
(labels ((r-encode-list (l)
(incf i)
(when (cdr l)
(r-encode-list (cdr l)))))
(r-encode-list l) i)))
(test (make-list 10000 :initial-element 0))
;; segmentation fault
This should be a somewhat deem problem, so for now why don't you try to overwrite the encode-list
using dolist
instead?
c.f.
(defun test2 (l)
(let ((i 0))
(dolist (val l)
(incf i))
i))
(test2 (make-list 100000 :initial-element 0))
;; ok
Thanks @Affonso-Gui for resolving the issue. Following your suggestion, I overrode the encode-list
function by the following function:
(defun encode-list (lst_ &optional (os *standard-output*))
(let ((lst (append lst_ '(:end))))
(with-blacket os #\[ #\]
(dolist (elem lst)
(encode-element elem os)
(unless (eq elem :end) (write-byte #\, os))))))
and it works fine as expected.
I'm using
json-encode-element
function ofroseus/roseus_mongo
defined here.When I pass an alist that has large size list as a value to the function, segmentation fault error occurs.
The both
save-json-test
andoutput-json-test
work fine unless N is large. However, when I setN=10000 or larger
for example, the both cause segmentation fault errors.