Debugging infinite loops and rackunit

I'm running Racket 8.6 [CS] on Debian

The following program has an infinite loop in it which makes it a bit of
challenge for the DrRacket debugger. It is interruptible from the normal
run (F5) but not from hitting "Go" in the debugger. In the latter case
DrRacket switches the label of Stop to Kill, but then seems to freeze
after printing a row of dashes.

#lang racket
(require rackunit)

(define (list-length list)
  (if (empty? list)
      (+ 1 (list-length list))))

(module+ test
  (check-equal? (list-length '(1 2 3))))

If I pull the check-equal? out of the submodule, then I actually get
an exception in the interaction window

../../../../../../usr/share/racket/pkgs/drracket/gui-debugger/annotator.rkt:75:40: user break
. . ../../../../../../usr/share/racket/pkgs/drracket/drracket/private/module-language.rkt:463:8: module->namespace: module not instantiated in the current namespace

And in this case Kill seems to work.

If get rid of the check-equal?, and just call list-length at the top level

(define (list-length list)
  (if (empty? list)
      (+ 1 (list-length list))))
(list-length '(1 2 3))

it seems to behave reasonably both in the debugger and outside (albeit
Stop is a bit slow to respond).

This seems like a bug to me, but I feel like it has been discussed
before in the pre-racket-cs days.

1 Like