Fix #2783: detect black-hole loops properly