asciidoctorj icon indicating copy to clipboard operation
asciidoctorj copied to clipboard

exception containing itself as nested exception, causing maven endless loop

Open Bananeweizen opened this issue 2 years ago • 7 comments

I've just raised an issue in Maven: https://issues.apache.org/jira/browse/MNG-7846 It's caused by an exception in JRuby when using the asciidoctor-maven-plugin.

Can one of the developers here say whether that exception is created somewhere in the code of AsciidoctorJ, or is this something to be reported for JRuby (or somewhere completely different even)? I'm trying to get the actual root cause fixed, the exception containing itself. If I'm wrong here, feel free to close.

Bananeweizen avatar Jul 19 '23 12:07 Bananeweizen

The AsciidoctorCoreException is simply wrapping the exception coming from JRuby, with no manipulation.

https://github.com/asciidoctor/asciidoctorj/blob/088e373c520bd59a6d0071cdd9c5090c0d858655/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java#L330

https://github.com/asciidoctor/asciidoctorj/blob/088e373c520bd59a6d0071cdd9c5090c0d858655/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JRubyAsciidoctor.java#L412

Can you provide a reproducer or the repo that's causing the issue? That way we can look further and see what flow inside JRuby is causing it.

abelsromero avatar Jul 19 '23 16:07 abelsromero

That's weird. Intuitively I would say that I see such circular references every day when debugging any problem in whatever software. Or am I totally wrong here?

Also looking at this old question on SO it seems like this is not uncommon: https://stackoverflow.com/questions/9233638/is-there-any-reason-to-set-an-exceptions-cause-to-itself

We can of cause argue whether it's a bad design or not, but I would say that if this is common in many libraries Maven should be able to handle that.

robertpanzer avatar Jul 20 '23 07:07 robertpanzer

That's weird. Intuitively I would say that I see such circular references every day when debugging any problem in whatever software. Or am I totally wrong here?

Not weird, I had to research too because I had the same idea 😄 It's normal but getCause should return the null if there's such self-reference. image

Seeing the stacktrace from the JIRA it comes from RubyLoadError which in turn ends up extending this suspicious method https://github.com/jruby/jruby/blob/73d3c1e3b5d0b6f5b774e32c30303a8d2bddb3c6/core/src/main/java/org/jruby/RubyException.java#L411-L413. But I'd like to confirm, hence the reproducer, we had had plenty of JRuby errors and never looped, I'd like to know what is the origin of the error.

abelsromero avatar Jul 20 '23 09:07 abelsromero

Just FTR Maven 3.9.4 (coming soon) have a fix for this issue, while we still think this is "not our bad". https://github.com/apache/maven/commit/36db1e35cac5e8c72bf0c795dd08756e50079e05

Also reported to JRuby https://github.com/jruby/jruby/issues/7861

cstamas avatar Jul 20 '23 09:07 cstamas

Just FTR Maven 3.9.4 (coming soon) have a fix for this issue, while we still think this is "not our bad". apache/maven@36db1e3

Also reported to JRuby jruby/jruby#7861

We are aware, I saw the posts, but I think we can do better than cross-posting. I am personally working on assumptions, not even the versions for asciidoctor-maven-plugin or AsciidoctorJ have been provided, and I haven't been able to cause a similar error on the latest releases. If a reproducer can be provided, which I assume exists and is likely to be an open-source repo, I can pinpoint the exact repo, branch, and line of code. That will help to move the upstream fix much quicker and reduce guesses.

abelsromero avatar Jul 20 '23 12:07 abelsromero

@abelsromero Unfortunately this is in a company project, and it hasn't even build a build on a commit, but rather on uncommitted changes. Since I've only found that looping process several hours later, and investigated it via heap dump, I can't even say what had been done when it was started. I do know that I had played around with enabling hyphenation, and that I had caused an error message by using a non supported language code via <hyphens>en</hyphens> in asciidoctor-maven-plugin attributes (instead of the correct en_us or en_uk), but I have not been able to reproduce that error situation by running several variations of this. I'm sorry, but it seems I cannot provide a reproducer.

Bananeweizen avatar Jul 20 '23 14:07 Bananeweizen

Thanks, at least that's something, we know now it's PDF with a theme. We found a suspicious method in jRuby. It's a matter of making a path between those 2 points.

abelsromero avatar Jul 23 '23 21:07 abelsromero