Project

Profile

Help

Bug #4371

Saxon/C crashing in browser when run via PHP

Added by O'Neil Delpratt 9 months ago. Updated 3 months ago.

Status:
In Progress
Priority:
High
Category:
PHP API
Start date:
2019-11-01
Due date:
% Done:

0%

Estimated time:
Found in version:
1.2.1
Fixed in version:

Description

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.

php7_saxon.cpp (181 KB) php7_saxon.cpp O'Neil Delpratt, 2020-05-12 15:49

History

#1 Updated by O'Neil Delpratt 9 months ago

Update:

Still investigating this issue, but what I am noticing is that we are getting intermitted hanging in the browser. Sometimes the script run and sometimes it does not.

#2 Updated by O'Neil Delpratt 9 months ago

  • Status changed from New to In Progress

Update:

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.

#3 Updated by O'Neil Delpratt 9 months ago

The fix made in bug issue #2055 is the cause of the hanging issue in the browser.

#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.

#6 Updated by Michael Kay 8 months ago

Rein, thank you, we do realise this bug is a show-stopper for many users. It's often the case, however, that bugs like this can be the hardest ones to fix, and if it takes time, that's because of the difficulty of the problem, not because of lack of urgency.

#7 Updated by O'Neil Delpratt 4 months ago

  • File php7_saxon.cpp added

Added patch for the hanging issue to the file php7_saxon.cpp

#8 Updated by O'Neil Delpratt 3 months ago

  • File deleted (php7_saxon.cpp)

Please register to edit this issue

Also available in: Atom PDF