Saxon/C crashing in browser when run via PHP
Reported by user:
Saxon-PE/C is crashing when run through the browser. It runs fine when PHP is run from the command-line.
I have managed to reproduce the issue.
#2 Updated by O'Neil Delpratt 9 months ago
- Status changed from New to In Progress
I have reinstalled Saxon/C PHP 1.1.2 version which runs as expected in the browser.
I also tried rolling back the PHP extension code from 1.1.2 release for Saxon/C 1.2. After making some minor changes to get the code compiling, I found the PHP script also runs fine in the browser.
Therefore I have narrowed down that the bug has been introduced in the PHP extension code between 1.1.2 and 1.2.1. This rules out the Excelsior Jet version change in the equation.
#4 Updated by Rein Baarsma 8 months ago
This bug is quite critical -- the extension is completely useless from 1.2.0 onwards for us. We had hoped to fix the memory problems by upgrading, but needed to downgrade directly after.
I've confirmed this bug is happening in the browser and functional tests, but not in unit tests and command line. It hangs consistently on every try.
We hope this issue will be fixed soon.
If it were up to me, I would change the severity to the highest option and "Found in version" to 1.2.0+
#5 Updated by O'Neil Delpratt 8 months ago
Hi, after much investigation I have got to the bottom of the problem but not yet yet worked out a solution.
We have some incompatibility with the cross compile tool we use (i.e. Excelsior JET) and PHP. The JET JNI environment is created as a static variable at the start of the program and released at the end.
The threads are created by the JET Runtime, e.g. GC thread, weak reference handler thread, finalizers thread, etc. Initially I thought best to create the Jet runtime for each request, but this did not work. So I tried to keep the Jet runtime alive for the lifetime of the extension, which could be reused between requests.
In the PHP extension we create the JET runtime (which has several threads) in the PHP_MINIT_FUNCTION(saxonc)
To make sure the clean up of the JET threads happens we have added a release method in the MSHUTDOWN_FUNCTION of the PHP extension.
The problem is when we run the PHP extension in the browser it just hangs. If we remove the code to manage the JET threads in the PHP_MINIT_FUNCTION the PHP scripts run, but does not kill the JET threads. The only way to kill the threads is a restart to the server.
In effect we need to reuse the JET threads between the PHP requests or find some way of killing them off.
I will revisit this problem again. We have one user resort to the shell_exec in the PHP script to run the Saxon/C extension.
Please register to edit this issue