Bug #4151

support of compileFromStringAndSave / compileFromFileAndSave + PHP5 build

Added by sébastien bocahu over 1 year ago. Updated 10 months ago.

Start date:
Due date:
% Done:


Estimated time:
Found in version:
Fixed in version:


Hi Saxonica team,

We would like to use the latest Saxon-HEC release, 1.1.2, that is supposed to bring support for compileFromStringAndSave / compileFromFileAndSave methods.

Unfortunately we have ran into issues with:

  1. building for PHP5: Fortunately, fix seems to be obvious: getUnderlyingValue() takes not arguments (see the attached patch)

  2. building for PHP5 w/ support for compileFromStringAndSave / compileFromFileAndSave methods: it seems that these features where added to PHP7 only. I tried to port it to PHP5, which was OK to compile & link (see attached patch)

  3. using compileFromFileAndSave(): resulted in a segfault. I can't tell if it that's my patch that is wrong or something happening in the JET Saxon library...

output: xml error0

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: system exception at 0x00000000007026ee Please, contact the vendor of the application.

From the coredump:

PHP & module are not built with debugging symbols so backtrace lacks info: #0 0x00007fe9f8ed5067 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #1 0x00007fe9f8ed6448 in __GI_abort () at abort.c:89 #2 0x00007fe9e8fa6b74 in ?? () from /usr/lib/ #3 0x0000000000000000 in ?? ()

And JET log: Signal 11 (SIGSEGV) siginfo: si_signo 11, si_errno 0, si_code 1, si_addr 0x0000000000000000 ...

I can provide you with more info if needed.

  1. it seems to me that even PHP7 misses some bits to get support of compileFromStringAndSave / compileFromFileAndSave methods: they should be registered into zend_function_entry XsltProcessor_methods[], shouldn't they ?

We would be glad to be have to use these methods in both php5 and php7 versions. Please feel free to ask for more info & test if needed.

Best regards,


saxon.diff (2.62 KB) saxon.diff sébastien bocahu, 2019-03-05 09:33

Related issues

Related to Saxon/C - Bug #4271: Saxon/C extension installation at Ubuntu 16.04 dont works!Rejected2019-08-06

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>


#1 Updated by Michael Kay over 1 year ago

  • Project changed from Saxon to Saxon/C
  • Category set to PHP API
  • Assignee set to O'Neil Delpratt

#2 Updated by O'Neil Delpratt over 1 year ago

  • Status changed from New to In Progress
  • Found in version set to 1.1.2

Thanks for reporting the issue you have found.

Firstly, As you mentioned the PHP code is incomplete. These methods need to be added to the 'XsltProcessor_methods'. I will fix this and commit to subversion.

Secondly, the methods to create a SEF file compileFromStringAndSave and compileFromFileAndSave require Saxon-EE/C. Saxon-HE/C can be used to load the SEF files once created. This is probably the cause of the Seg Error. I will investigate this further. This should in no doubt fail more cleanly.

#3 Updated by O'Neil Delpratt over 1 year ago

The methods in Java compileFromStringAndSave and compileFromFileAndSave incorrectly catches the SaxonApiException instead of throwing it. I can see this causing the problem reported in PHP.

Fixed in the Java code.

#4 Updated by O'Neil Delpratt over 1 year ago


the following exception is probably the cause of why this method is failing:

net.sf.saxon.s9api.SaxonApiException: Exporting a package is only possible if just-in-time compilation is disabled
	at Source)
	at Source)
	at net.sf.saxon.option.cpp.XsltProcessor.compileFromFileAndSave(Unknown Source)
Caused by: net.sf.saxon.trans.XPathException: Exporting a package is only possible if just-in-time compilation is disabled
	at Source)
	... 3 more

It would be good to switch on and off Just-In-Time compilation via the C++/PHP API. I have created another bug issue to track this: #4156

As mentioned in the bug issue the workaround is as follows:


#5 Updated by sébastien bocahu over 1 year ago

I tried (still using Saxon-HEC) but still got a segfault:

$saxonProc = new Saxon\SaxonProcessor();

$xsltProc = $saxonProc->newXsltProcessor();

$xsltProc->compileFromFileAndSave($xslFile, $xslFile.".sef");

#6 Updated by O'Neil Delpratt over 1 year ago


As mentioned in comment #2. The exporting feature is not available in Saxon-HE/C, you will require Saxon-EE/C. You can get an evaluation license to try it out

Then you can use the following code:

$saxonProc = new Saxon\SaxonProcessor(true);

$xsltProc = $saxonProc->newXsltProcessor();

$xsltProc->compileFromFileAndSave($xslFile, $xslFile.".sef");

#7 Updated by O'Neil Delpratt over 1 year ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Bug fixed.

#8 Updated by O'Neil Delpratt 12 months ago

  • Related to Bug #4271: Saxon/C extension installation at Ubuntu 16.04 dont works! added

#9 Updated by O'Neil Delpratt 10 months ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 1.2.0

Big fix applied in the Saxon/C 1.2.0 release.

Please register to edit this issue

Also available in: Atom PDF