Menu

#84 Tag and StartTag static init deadlock under heavy load

General
open-fixed
nobody
None
5
2016-10-01
2015-12-23
No

Description:
net.htmlparser.jericho.Tag dependency on net.htmlparser.jericho.StartTag (a sub class) during its static initialization, creates deadlock when accessed concurrently.

I discovered this bug while running our Unit Tests with testng in a threadpool. The tests would hang and the thread-dumps pointed to Jericho. I attached a threaddump when the tests were hanging.

I then looked at the code and found some interesting static initialization in the Tag class.

I attached a simplified test case where you can reproduce the deadlock (you may need to tweak the delays depending on your machine).

Some interesting things to read:
https://bugs.openjdk.java.net/browse/JDK-8037567
https://bugs.openjdk.java.net/browse/JDK-8139224

Solution:
Get rid of the static initialization that can create the deadlock.

2 Attachments

Discussion

  • Martin Jericho

    Martin Jericho - 2015-12-24

    Thanks for the bug report Guislain. I sometimes wonder how the jvm figures out these complex static initialisation dependencies and assumed if it works once it is all good. I'll have a look at fixing it when I have time. In the meantime you could probably avoid the problem by making sure the StartTag class is initialised in your main thread before starting other threads.

     
  • Martin Jericho

    Martin Jericho - 2016-10-01
    • status: unread --> open-fixed
     
  • Martin Jericho

    Martin Jericho - 2016-10-01

    Hi Guislain,

    I have (hopefully) fixed this in version 3.5.

    Until version 3.5 is officially released, the development version is available here:
    http://jericho.htmlparser.net/temp/jericho-html-3.5-dev.zip

    If you don't mind could you please run your test again and verify that the deadlock no longer happens?

    Regards
    Martin

     

Log in to post a comment.