I tested without use-caps-for-id, and did not get the "looping module stopped" error.
I also upgraded to 1.6.7 and applied your patch. Here is a sample of some of the queries and log messages I got. I was loading Unbound with a mixture of A and CAA queries pulled from the logs of all names in certificates issued by Let's Encrypt. Oct 14 18:43:22 unbound[8613:0] error: internal error: looping module (iterator) stopped Oct 14 18:43:22 unbound[8613:0] info: pass error for qstate autodiscover.azhany.com. A IN -- Oct 14 18:52:08 unbound[8613:1] error: internal error: looping module (iterator) stopped Oct 14 18:52:08 unbound[8613:1] info: pass error for qstate ferrinho.pt. A IN -- Oct 14 18:56:14 unbound[8613:0] error: internal error: looping module (iterator) stopped Oct 14 18:56:14 unbound[8613:0] info: pass error for qstate akembroidery.net. NS IN -- Oct 14 19:16:51 unbound[8613:0] error: internal error: looping module (iterator) stopped Oct 14 19:16:51 unbound[8613:0] info: pass error for qstate yellowbuckle.com. NS IN -- Oct 14 19:17:16 unbound[8613:1] error: internal error: looping module (iterator) stopped Oct 14 19:17:16 unbound[8613:1] info: pass error for qstate www.durkeim.com. A IN -- Oct 14 19:22:30 unbound[8613:0] error: internal error: looping module (iterator) stopped Oct 14 19:22:30 unbound[8613:0] info: pass error for qstate www.kolorbandit.com. A IN -- Oct 14 19:23:33 unbound[8613:0] error: internal error: looping module (iterator) stopped Oct 14 19:23:33 unbound[8613:0] info: pass error for qstate kolorbandit.com. NS IN -- Oct 14 19:35:33 unbound[8613:1] error: internal error: looping module (iterator) stopped Oct 14 19:35:33 unbound[8613:1] info: pass error for qstate biggiejobs.com. NS IN -- Oct 14 19:38:09 unbound[8613:1] error: internal error: looping module (iterator) stopped Oct 14 19:38:09 unbound[8613:1] info: pass error for qstate vanicious.com. NS IN Also worth noting: I set up this test harness in order to reproduce an issue with harden-referral-path where all queries time out after a certain amount of time. However, I suspect the "looping module stopped" issue is separate because I get that message even in test runs with harden-referral-path disabled. I'll file an issue with details about the timeout problem soon.
