Improve detection of infinite recursion for PecanHook and pypy.

Fixes bug 1394344

Change-Id: I1c33598c4187e92f48691a8b6ef0663b09ce7240
Merge "Improve detection of infinite recursion for PecanHook and pypy."