# Debugging infinite loops and rackunit

**URL:** https://racket.discourse.group/t/debugging-infinite-loops-and-rackunit/1307
**Category:** General
**Created:** [September 17, 2022, 12:52pm UTC](https://racket.discourse.group/t/debugging-infinite-loops-and-rackunit/1307 "2022-09-17T12:52:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bremner](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bremner](https://racket.discourse.group/u/bremner)
#### Post date: [September 17, 2022, 12:52pm UTC](https://racket.discourse.group/t/debugging-infinite-loops-and-rackunit/1307/1 "2022-09-17T12:52:23Z")

</div>

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.

```scheme
#lang racket
(require rackunit)

(define (list-length list)
  (if (empty? list)
      0
      (+ 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

```scheme
../../../../../../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
  name:
  #<resolved-module-path:"/home/bremner/teaching/cs2613/labs/L04/loop2.rkt">

```

And in this case Kill seems to work.

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

```scheme
(define (list-length list)
  (if (empty? list)
      0
      (+ 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.
