Skip to content

Infinite Loop in Table.drawRow() with Large Content and Headers #306

Description

@raikowagner

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:

  1. Paragraph.getHeight(lineStart) with lineStart = Integer.MAX_VALUE
  2. The condition if (getLines().size() <= lineStart) evaluates to true
  3. The method returns 0, making the header appear to have a height of paddings and borders and no content height
  4. The available space calculation becomes incorrect
  5. the content row appears to fit on a new page
  6. a new page is created which gets a new header
  7. 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

  • Boxable Version: 1.8.2

Impact

  • Critical - Causes OOM and application crash during PDF generation
  • affects any table with headers and large content rows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions