Infinite Loop in Table.drawRow() with Large Content and Headers
Summary
When drawing a table with headers and a content row that is too tall to fit on a page, Boxable enters an infinite loop creating blank pages instead of properly handling the page break.
Root Cause
The bug occurs in Table.java during the header height recalculation on a new page. After a row is drawn, the Cell.lineStart value is set to Integer.MAX_VALUE (line 1022). When the height of header cells is recalculated for the new page, Paragraph.getHeight(Integer.MAX_VALUE) is called, which causes:
Paragraph.getHeight(lineStart) with lineStart = Integer.MAX_VALUE
- The condition
if (getLines().size() <= lineStart) evaluates to true
- The method returns 0, making the header appear to have a height of paddings and borders and no content height
- The available space calculation becomes incorrect
- the content row appears to fit on a new page
- a new page is created which gets a new header
- because the content height did not change, and it won't get split, an infinite loop of header only page creation is started
Expected Behavior
- Header height should be calculated correctly when checking if content could fit on a new page
Actual Behavior
- application eventually runs out of memory (OOM)
Environment
Impact
- Critical - Causes OOM and application crash during PDF generation
- affects any table with headers and large content rows
Infinite Loop in Table.drawRow() with Large Content and Headers
Summary
When drawing a table with headers and a content row that is too tall to fit on a page, Boxable enters an infinite loop creating blank pages instead of properly handling the page break.
Root Cause
The bug occurs in
Table.javaduring the header height recalculation on a new page. After a row is drawn, theCell.lineStartvalue is set toInteger.MAX_VALUE(line 1022). When the height of header cells is recalculated for the new page,Paragraph.getHeight(Integer.MAX_VALUE)is called, which causes:Paragraph.getHeight(lineStart)withlineStart = Integer.MAX_VALUEif (getLines().size() <= lineStart)evaluates totrueExpected Behavior
Actual Behavior
Environment
Impact