Project

Profile

Help

Bug #6425

closed

When the saxon:thread attribute is set for xsl:for-each in saxon-ee-12.4 (enterprise edition), NullPointException and ClassCastException occasionally occur in multi-thread scenarios.

Added by lu zhang 6 months ago. Updated 6 months ago.

Status:
Duplicate
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2024-05-15
Due date:
2024-06-30
% Done:

0%

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

Description

When the saxon:thread attribute is set for xsl:for-each in saxon-ee-12.4 (enterprise edition), NullPointException and ClassCastException occasionally occur in multi-thread scenarios.

Caused by: java.lang.NullPointerException at net.sf.saxon.expr.XPathContextMajor.getTargetComponent(XPathContextMajor.java:684) at net.sf.saxon.expr.instruct.ApplyTemplates.getTargetMode(ApplyTemplates.java:303) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:613) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)

or

Caused by: java.lang.ClassCastException: net.sf.saxon.expr.Component cannot be cast to net.sf.saxon.expr.Component$M at net.sf.saxon.expr.instruct.ApplyTemplates.getTargetMode(ApplyTemplates.java:303) at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesElaborator.lambda$elaborateForPush$1(ApplyTemplates.java:613) at net.sf.saxon.expr.instruct.Block$BlockElaborator.lambda$elaborateForPush$4(Block.java:895) at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:376)

Cause: processComponentReference method of net.sf.saxon.expr.instruct.Actor

int slot = bindings.size();
ComponentBinding cb = new ComponentBinding(name, target);
bindings.add(cb);
invocation.setBindingSlot(slot);

The operation of obtaining the slot and adding the slot to the bindings is not an atomic operation. In the multi-thread scenario, the positions of the slot and bindings may be mismatched or overwritten.

Solution (s): Ensure that the slot obtaining and adding operations are atomic and the performance in multi-thread scenarios is ensured.:


Related issues

Is duplicate of Saxon - Bug #6348: net.sf.saxon.expr.XPathContextMajor.getTargetComponent throws NullPointerException - race conditionClosedMichael Kay2024-02-15

Actions
Actions #1

Updated by Michael Kay 6 months ago

Thanks for reporting it, and especially for digging so deeply into the code to find the cause.

Your proposed solution is in fact exactly the change that we made in response to bug #6348 (after a very tortuous process of debugging - so congratulations on finding it). So I'm going to close this as a duplicate.

We're hoping to get a 12.5 maintenance release out very soon, which will include this patch.

Actions #2

Updated by Michael Kay 6 months ago

  • Status changed from New to Duplicate
  • Assignee changed from Community Admin to Michael Kay
  • Priority changed from High to Normal
  • Applies to branch 9.4 added
  • Applies to branch deleted (12)
Actions #3

Updated by Michael Kay 6 months ago

  • Is duplicate of Bug #6348: net.sf.saxon.expr.XPathContextMajor.getTargetComponent throws NullPointerException - race condition added

Please register to edit this issue

Also available in: Atom PDF