Skip to content

Instantly share code, notes, and snippets.

@knorth55
Last active September 2, 2021 12:31
Show Gist options
  • Save knorth55/5f0e02f8c0103323d51d04aea482f57a to your computer and use it in GitHub Desktop.
Save knorth55/5f0e02f8c0103323d51d04aea482f57a to your computer and use it in GitHub Desktop.
euslisp-apply-funcall-segmentation-fault-test
(defun spam1 (x)
(setq *spam-func* #'spam1)
(format t "spam1: ~A ~%" x)
(unix::sleep 1))
(defun spam2 (x)
(setq *spam-func* #'(lambda (xx) (spam2 xx)))
(format t "spam2: ~A ~%" x)
(unix::sleep 1))
(defun spam3-test (xx)
(format t "spam3-test: ~A ~%" xx)
(unix::sleep 1))
(defun spam3 (x)
(setq *spam-func* #'spam3-test)
(format t "spam3: ~A ~%" x)
(unix::sleep 1))
(defun spam4-test (xx)
(format t "spam4-test: ~A ~%" xx)
(unix::sleep 1))
(defun spam4 (x)
(setq *spam-func* #'(lambda (xx) (spam4-test xx)))
(format t "spam4: ~A ~%" x)
(unix::sleep 1))
(defun spam5 (x)
(setq *spam-func*
#'(lambda (xx)
(format t "spam5-lambda: ~A ~%" xx)))
(format t "spam5: ~A ~%" x)
(unix::sleep 1))
(defun spam6 (x)
(setq *spam-func*
`(lambda-closure nil 0 0 (xx)
(format t "spam6-lambda: ~A ~%" xx)))
(format t "spam6: ~A ~%" x)
(unix::sleep 1))
(defun noarg-spam1 ()
(setq *spam-func* #'noarg-spam1)
(format t "noarg-spam1: ~A ~%" nil)
(unix::sleep 1))
(defun noarg-spam2 ()
(setq *spam-func* #'(lambda () (noarg-spam2)))
(format t "noarg-spam2: ~A ~%" nil)
(unix::sleep 1))
(defun noarg-spam3-test (xx)
(format t "noarg-spam3-test: ~A ~%" xx)
(unix::sleep 1))
(defun noarg-spam3 ()
(setq *spam-func* #'noarg-spam3-test)
(format t "spam3: ~A ~%" nil)
(unix::sleep 1))
(defun noarg-spam4-test (xx)
(format t "noarg-spam4-test: ~A ~%" xx)
(unix::sleep 1))
(defun noarg-spam4 ()
(setq *spam-func* #'(lambda (xx) (noarg-spam4-test xx)))
(format t "noarg-spam4: ~A ~%" nil)
(unix::sleep 1))
(defun noarg-spam5 ()
(setq *spam-func*
#'(lambda (xx)
(format t "noarg-spam5-lambda: ~A ~%" xx)))
(format t "noarg-spam5: ~A ~%" nil)
(unix::sleep 1))
(defun noarg-spam6 ()
(setq *spam-func*
`(lambda-closure nil 0 0 (xx)
(format t "noarg-spam6-lambda: ~A ~%" xx)))
(format t "spam6: ~A ~%" nil)
(unix::sleep 1))
; ;; segmentation fault
; (spam1 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (funcall *spam-func* 1)
;; OK
(spam2 0)
(format t "*spam-func*: ~A~%" *spam-func*)
(funcall *spam-func* 1)
; ;; segmentation fault
; (spam1 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (apply *spam-func* (list 1))
; ;; segmentation fault
; (spam2 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (apply *spam-func* (list 1))
; ;; segmentation fault
; (spam3 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (apply *spam-func* (list 1))
; ;; segmentation fault
; (spam4 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (apply *spam-func* (list 1))
; ;; segmentation fault
; (spam5 0)
; (format t "*spam-func*: ~A~%" *spam-func*)
; (apply *spam-func* (list 1))
;; OK
(spam6 0)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* (list 1))
;; OK
(noarg-spam1)
(format t "*spam-func*: ~A~%" *spam-func*)
(funcall *spam-func*)
;; OK
(noarg-spam2)
(format t "*spam-func*: ~A~%" *spam-func*)
(funcall *spam-func*)
;; OK
(noarg-spam1)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* nil)
;; OK
(noarg-spam2)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* nil)
;; OK
(noarg-spam3)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* (list 1))
;; OK
(noarg-spam4)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* (list 1))
;; OK
(noarg-spam5)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* (list 1))
;; OK
(noarg-spam6)
(format t "*spam-func*: ~A~%" *spam-func*)
(apply *spam-func* (list 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment