Bug #6425
closedWhen 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.
0%
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
Updated by Michael Kay 8 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.
Updated by Michael Kay 8 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)
Updated by Michael Kay 8 months ago
- Is duplicate of Bug #6348: net.sf.saxon.expr.XPathContextMajor.getTargetComponent throws NullPointerException - race condition added
Please register to edit this issue