Skip to content

Regression in JRuby 10.1 with Prawn #9462

@jeremyevans

Description

@jeremyevans

Environment Information

This affects:

jruby 10.1.0.0 (4.0.0) 2026-04-20 32f988b78c OpenJDK 64-Bit Server VM 21.0.10+7-1 on 21.0.10+7-1 +indy +jit [x86_64-OpenBSD]
OpenBSD 7.9 amd64

as well as an Ubuntu 24.04 GitHub Runner (https://github.com/jeremyevans/tilt/actions/runs/26411921259/job/77748035355#step:5:563)

The gem showing incorrect behavior with JRuby 10.1 is Prawn.

Expected Behavior

Prawn on JRuby 10.1 should work as it does on JRuby 10.0 or CRuby 4.0.

Actual Behavior

Prawn on JRuby 10.1 produces incorrect PDFs after the 10th iteration. This doesn't happen on JRuby 10.0 or CRuby 4.0. Example tilt CI run: https://github.com/jeremyevans/tilt/actions/runs/26411921259/job/77748035355#step:5:563

While the exception occurs in pdf-reader, the actual problem is in Prawn, and is shown by this code:

require 'prawn'

11.times do
  pdf = ::Prawn::Document.new
  pdf.text "Hello PDF!"
  p pdf.render.to_str.bytesize
end

For the first 10 iterations, you get 911. For the last iteration, you get 899. The difference in the PDF produced in the 11th iteration:

--- good.pdf    Mon May 25 11:36:29 2026
+++ bad.pdf     Mon May 25 11:36:29 2026
@@ -39,8 +39,7 @@
 /CropBox [0 0 612 792]
 /MediaBox [0 0 612 792]
 /Parent 3 0 R
-/Resources << /Font << /F1.0 6 0 R
->>
+/Resources << /Font << >>
 /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
 >>
 /TrimBox [0 0 612 792]
@@ -62,12 +61,12 @@
 0000000158 00000 n
 0000000215 00000 n
 0000000333 00000 n
-0000000599 00000 n
+0000000587 00000 n
 trailer
 << /Info 1 0 R
 /Root 2 0 R
 /Size 7
 >>
 startxref
-696
+684
 %%EOF

I worked around this in tilt by modifying the tests to not run more than 10 iterations, and that made CI pass: https://github.com/jeremyevans/tilt/actions/runs/26414918691

Maybe there is some internal misoptimization that runs after 10 iterations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions