Project

Profile

Help

Bug #2327

closed

Deadlock for concurrent instantiation of Configuration and EnterpriseConfiguration

Added by Gunther Rademacher about 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Multithreading
Sprint/Milestone:
Start date:
2015-03-12
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

Our test suite occasionally was hanging with some threads showing call stacks, where Saxon configuration objects were being instantiated. After some deeper analysis, I can now reproduce it with the attached test program.

In this setup one thread instantiates EnterpriseConfiguration (originally in order to proceed with activation of the license), while the other instantiates Configuration (originally on behalf or TransformerFactory.newInstance). The problem appears to be caused by

  • the former accessing EnterpriseConfiguration, then Configuration (as it is the super class), while

  • the latter accessing Configuration, then EnterpriseConfiguration (by Class.forName during static initialization),

and this turns out to produce a deadlock. Instantiation of ProfessionalConfiguration presumably would cause the same problem.

It can be worked around by accessing the Configuration Class object beforehand. We will be using the workaround now, but thought you might be interested.

The output of the attached test program is:

both threads alive after 2 sec
both threads alive after 4 sec
both threads alive after 6 sec
both threads alive after 8 sec
both threads alive after 10 sec
stack trace:
  InstantiationProblem$1.run(InstantiationProblem.java:18)
stack trace:
  java.lang.Class.forName0(Native Method)
  java.lang.Class.forName(Class.java:259)
  net.sf.saxon.Configuration.makeConfigurationClass(Configuration.java:4448)
  net.sf.saxon.Configuration.<clinit>(Configuration.java:113)
  InstantiationProblem$2.run(InstantiationProblem.java:24)

Best regards,

Gunther


Files

InstantiationProblem.java (1.39 KB) InstantiationProblem.java Reproduction of issue Gunther Rademacher, 2015-03-12 16:56

Please register to edit this issue

Also available in: Atom PDF