Bug #2204

Nested multithreaded xsl:for-each

Added by Michael Kay over 5 years ago. Updated about 4 years ago.

Saxon extensions
Start date:
Due date:
% Done:


Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Saxon-EE allows an xsl:for-each instruction to operate in multithreaded mode by specifying the extension attribute saxon:threads="N".

This fails (typically causing the VM to hang) if several concurrent executions of the same multithreaded xsl:for-each instruction occur in parallel.

This might happen because the multithreaded xsl:for-each is nested (statically or dynamically) in another multithreaded xsl:for-each, or because the stylesheet containing the multithreaded xsl:for-each instruction is itself executed several times in parallel, for example by creating several XsltTransformer instances from the same XsltExecutable.

The problem has been re-created in a reproduceable test case, and a patch has been tested on the 9.6 branch.


#1 Updated by Michael Kay over 5 years ago

  • Status changed from New to Resolved

Now fixed on the 9.5, 9.6, and 9.7 branches.

The problem was that two variables (maxThreads and executionPool) evaluated during the course of evaluating the xsl:for-each instruction are held in instance-level variables of the MultithreadedForEach class, which is an expression class and therefore part of the compiled stylesheet, which is supposed to be threadsafe. It proved easy to change these to local variables held on stack.

The test case used was an adapted version of XSLT 3 test case catalog-005, adapted to put saxon:threads on two nested loops. No permanent test case has been created.

#2 Updated by O'Neil Delpratt over 5 years ago

Bug fix applied in the Saxon maintenance release

#3 Updated by O'Neil Delpratt over 5 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to

Bug fix applied to the maintenance release Saxon

#4 Updated by O'Neil Delpratt about 4 years ago

  • Sprint/Milestone set to
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release added

Please register to edit this issue

Also available in: Atom PDF