11

I have an infinite loop somewhere in my program resulting in a <<loop>> exception when run normally. Using GHCi, I've tracked the problem down to a thunk

f = Constructor1
  (Constructor2 A :
   (_t3::[DataType2]))

Attempting to sequence the thunk with seq _t3 () results in GHCi hanging, so if I understand correctly the infinite loop is occurring in the reduction to Weak Head Normal Form. Is there any way to investigate this thunk, for example to see step by step the reduction steps attempting to be used to evaluate it?

Alec
  • 31,829
  • 7
  • 67
  • 114
Corey Staten
  • 545
  • 4
  • 12
  • Is there a way to narrow down the problematic piece and make it short enough to post here? If it can't be narrowed down (e.g. by making enough related definitions trivial), why? – 9000 Oct 05 '17 at 16:19
  • 1
    I can't figure out a way to narrow it down; that's exactly what I'm hoping to do by asking this question. This is happening inside of a very large program, and the lazy generation of the infinite loop doesn't seem to be happening anywhere near the point of evaluation of the thunk. I would like to know where in my program that thunk is coming from; for instance, is it a call to a certain known function with certain known parameters. – Corey Staten Oct 05 '17 at 16:28
  • A related thread: https://stackoverflow.com/q/5337419/223424 – 9000 Oct 05 '17 at 16:53
  • I've looked at that thread; :history was not revealing, and running the program with profiling terminates quickly due to loop detection, so nothing obvious stands out as the loop location. – Corey Staten Oct 05 '17 at 19:00
  • 3
    Can you enable stack trace on exception and then Ctrl-C during the infinite loop? – Alex R Oct 07 '17 at 21:08
  • That doesn't seem to work; see here: https://stackoverflow.com/questions/47188857/ghci-hangs-when-ctrlcing-from-infinite-loop-with-fbreak-on-exception-set – Corey Staten Nov 08 '17 at 20:16

0 Answers0