Here at IDRSolutions, one of the features of our JPedal library is a PDF to image converter. Occasionally we get bug reports from our customers, and if there is an issue in our code we can generally fix it very quickly. However, sometimes we see issues which are specific to the JVM and these can be complex to fix.
This bug is actually related to one we flagged on our blog in the article Interesting PDF bugs – tiny dash values and the Java JVM. In this case, the JVM was crashing when the dash array contained very small values. This was in 2012 and the code was run on Java 6.
Four years and two releases of Java later, we are still seeing a related error. A customer recently sent in another file which caused Java to crash when using our library. After spending some time debugging the code to find exactly where the crash was happening, we found that the problem was again related to the Stroke class. As with the previous case, it was an issue with drawing a dotted line.
This time, the crash happened when:
- the dash phase was equal to 0,
- the dash array was not null and
- the shape had an end curve.
This kind of error is particularly nasty because it can be very hard to debug. We now have a workaround for this which stops the crash. It is also worrying that something as simple as setting a value can cause the JVM to crash.
Have you ever come across this error? What was your solution?
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.