Subject: 27.2; EDebugging stops when breakpoint condition can not be printed

From: Петров Андрей <[email-masked]>
Date: Tue, 14 Dec 2021 13:03:51 +0000

Hello, team!
The following code can reproduce the bug:

(require 'cl-lib)
(require 'eieio)

(defclass my-field ()
  ((from-types :initform nil)
   (type :initform nil)))

(defun test ()
  "Demonstrates edebug condition printing bug.
1. evaluate the buffer
2. instrument `test' function for debugging
3. add conditional breakpoint inside lambda below (see comment)
   M-x edebug-set-conditional-breakpoint [RET] root [RET]
4. Start the function for debugging
   M-x (test)
5. Continue to the breakpoint
   c

Now error: \"Apparently circular structure being printed\" is
printed and no further debugging is possible.
"
  (let* ((root (my-field))
	 (tmp root))
    (dotimes (i 100)
      (let ((a (my-field)))
	(push a (oref tmp type))
	(push tmp (oref a from-types))
	(setf tmp a)))
    (push root (oref tmp type))    
    (cl-remove root '(1 2 3 4) :test (lambda (a b) ;; <-- put cursor here and set
				       ;; conditional breakpoint with condition: root
				       (= (length (oref a from-types))) b))
    (cl-remove root '(1 2 3 4) :test (lambda (a b) (= (length (oref a from-types))) b))
    (cl-remove root '(1 2 3 4) :test (lambda (a b) (= (length (oref a from-types))) b))
    "Finished"
    ))

It hard for me to get backtraces on the example but on other
(complicated) code I got the following using recursive edit:

Debugger entered--Lisp error: (error "Apparently circular structure being printed")
  apply(debug error (error "Apparently circular structure being printed"))
  edebug(error (error "Apparently circular structure being printed"))
  signal(error ("Apparently circular structure being printed"))
  edebug-signal(error ("Apparently circular structure being printed"))
  message("Break: %s => %s" filtered (#<field field-157aa078be4c>))
  edebug--display-1(nil 0 before)
  edebug--display(nil 0 before)
  edebug-debugger(0 before nil)
  edebug-before(0)
  (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after (edebug-before 3) 10 (if (edebug-after 0 4 filtered) (edebug-after (edebug-before 5) 8 (cl-remove (edebug-after 0 6 parent) (edebug-after 0 7 context) :count 1 :test (lambda (a b) (edebug-enter ... ... ...)))) (edebug-after 0 9 context)))))
  (lambda nil (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after (edebug-before 3) 10 (if (edebug-after 0 4 filtered) (edebug-after (edebug-before 5) 8 (cl-remove (edebug-after 0 6 parent) (edebug-after 0 7 context) :count 1 :test (lambda ... ...))) (edebug-after 0 9 context))))))()
  edebug-default-enter(edebug-anon17 (#<field field-157aa078be4c>) (lambda nil (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after (edebug-before 3) 10 (if (edebug-after 0 4 filtered) (edebug-after (edebug-before 5) 8 (cl-remove ... ... :count 1 :test ...)) (edebug-after 0 9 context)))))))
  edebug-enter(edebug-anon17 (#<field field-157aa078be4c>) (lambda nil (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after (edebug-before 3) 10 (if (edebug-after 0 4 filtered) (edebug-after (edebug-before 5) 8 (cl-remove ... ... :count 1 :test ...)) (edebug-after 0 9 context)))))))
  (lambda (parent) (edebug-enter 'edebug-anon17 (list parent) #'(lambda nil (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after ... 10 ...))))))(#<field field-157aa078be4c>)
  mapcan((lambda (parent) (edebug-enter 'edebug-anon17 (list parent) #'(lambda nil (edebug-after (edebug-before 0) 11 (find-inpas-paths (edebug-after 0 1 parent) (edebug-after 0 2 stop-id) (edebug-after ... 10 ...)))))) (#<field field-157aa078be4c>))

P.S. I could not copy the text from emacs with C-c M-i according to hint:
While in the mail buffer:

  Type C-c C-c to send the bug report.
  Type C-x k RET to cancel (don’t send it).
  Type C-c M-i to copy text to your preferred mail program.   <----

Andrey Petrov.