On a "simple-page-master" if the sum of "margin-top" and the "margin-bottom" is equal to or greater than the "page-height", Apache FOP will get stuck in an endless loop, continually generating pages in an attempt to add content that will never fit. Now clearly this is a user error, but FOP should make efforts to detect this scenario. Similarly, I would suspect that if the sum of "margin-left" and "margin-right" is equal to or greater than "page-width" another endless loop is caused. I've not tested this scenario, though
This bug has some relationships to bug #8778 which I've offered some commentary on. The same problem may be occurring in each case- a FO document is being generated such that some single element is spilling over the pagebreak, causing FOP to put it on a new page, where it then spills over the pagebreak...ad nauseum. The comments in bug #8778 were for FOP 0.20.3, but the bug hasn't been assigned or resolved, so it's probably valid in FOP 0.20.4. Any attempt at addressing this issue of the infinite looping should address both the cases mentioned here and in bug #8778 as well. Possibly a simple solution is to track whether or not FOP tries to position the same object on a new page more than twice? The moment an object is placed on a fresh, new page and cannot fit, there is no need to continue- no future pages are going to fit it, either.
The fix for bug #8778 should aid with this issue, though without real testing, that's only speculation. Thus far, it has caused loop termination in the other infinite looping bugs.
Bug fixed in latest Trunk (rev 584703), and probably in FOP 0.94
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed