Bug #4151
closedsupport of compileFromStringAndSave / compileFromFileAndSave + PHP5 build
100%
Description
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:
-
building for PHP5: Fortunately, fix seems to be obvious: getUnderlyingValue() takes not arguments (see the attached patch)
-
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)
-
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/libsaxonhec.so #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.
- 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,
Sebastien
Files
Related issues
Updated by Michael Kay over 5 years ago
- Project changed from Saxon to SaxonC
- Category set to PHP API
- Assignee set to O'Neil Delpratt
Updated by O'Neil Delpratt over 5 years 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.
Updated by O'Neil Delpratt over 5 years 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.
Updated by O'Neil Delpratt over 5 years ago
Update:
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 net.sf.saxon.s9api.XsltPackage.save(Unknown Source)
at net.sf.saxon.s9api.XsltPackage.save(Unknown 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 com.saxonica.ee.trans.StylesheetPackageEE.export(Unknown 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:
$processor->setConfigurationProperty("http://saxon.sf.net/feature/optimizationLevel","-j");
Updated by sébastien bocahu over 5 years ago
I tried (still using Saxon-HEC) but still got a segfault:
$saxonProc = new Saxon\SaxonProcessor();
$saxonProc->setConfigurationProperty("http://saxon.sf.net/feature/optimizationLevel","-j");
$xsltProc = $saxonProc->newXsltProcessor();
$xsltProc->setSourceFromFile($xmlFile);
$xsltProc->compileFromFileAndSave($xslFile, $xslFile.".sef");
Updated by O'Neil Delpratt over 5 years ago
Hi,
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);
$saxonProc->setConfigurationProperty("http://saxon.sf.net/feature/optimizationLevel","-j");
$xsltProc = $saxonProc->newXsltProcessor();
$xsltProc->setSourceFromFile($xmlFile);
$xsltProc->compileFromFileAndSave($xslFile, $xslFile.".sef");
Updated by O'Neil Delpratt over 5 years ago
- Status changed from In Progress to Resolved
- % Done changed from 0 to 100
Bug fixed.
Updated by O'Neil Delpratt over 5 years ago
- Related to Bug #4271: Saxon/C extension installation at Ubuntu 16.04 dont works! added
Updated by O'Neil Delpratt about 5 years 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