Project

Profile

Help

Bug #5943

open

XSLT through SaxonC PHP gives "Segmentation fault"

Added by Youri Lefers about 1 year ago. Updated 6 months ago.

Status:
AwaitingInfo
Priority:
Normal
Category:
-
Start date:
2023-03-28
Due date:
% Done:

0%

Estimated time:
Found in version:
12.0
Fixed in version:
Platforms:

Description

Hi all,

We've upgraded our SaxonC PHP library to Saxon 12(.1), but it gives a segmentation fault (error code 139 with PHPUnit) when it runs 2 or more transformations after each other. This happens in version 12.1, but also happened in version 12. We use PHP 8.1 (FPM).

We use a factory to construct and destruct a SaxonProcessor instance:

use Saxon\SaxonProcessor;

class SaxonProcessorFactory
{
    private ?SaxonProcessor $saxonProcessor = null;

    public function __destruct()
    {
        if (null !== $this->saxonProcessor) {
            $this->saxonProcessor = null;
        }
    }

    public function get(): SaxonProcessor
    {
        if (null === $this->saxonProcessor) {
            $this->saxonProcessor = $this->create();
        }

        return $this->saxonProcessor;
    }

    private function create(): SaxonProcessor
    {
        $saxonProcessor = new SaxonProcessor();
        $saxonProcessor->setConfigurationProperty('http://saxon.sf.net/feature/recognize-uri-query-parameters', 'true');

        return $saxonProcessor;
    }
}

Then we use that processor to do XSLT transformations:

$saxonProcessor = $this->saxonProcessorFactory->get();
$transformer = $saxonProcessor->newXslt30Processor();

foreach ($parameters as $key => $value) {
        $transformer->setParameter($key, $saxonProcessor->createAtomicValue($value));
}

$transformer->transformFileToFile($tmpFilePath, $xsltFilePath, $outputFile->getPath());
if ($transformer->exceptionOccurred()) {
        $exception = SaxonXsltTransformException::forXslTransformation($transformer, $tmpFilePath, $xsltFilePath);
        $transformer = null;
        throw $exception;
}

$transformer = null;

The first time it runs fine (through for example unit tests), but the second time it gives a segmentation fault. I'm unable to debug this into a specific line or something that created the segmentation fault.

Are you guys able to help us out?

Actions #1

Updated by Martin Honnen about 1 year ago

Just to understand, where did you originally upgrade from? SaxonC 11.x to 12.x?

Actions #2

Updated by Youri Lefers about 1 year ago

So, we've used version 1.1.2 for quite some time and we've updated that some time ago to version 1.2.1.

I've tested the update to version 11 just recently, and it gave the same issue, but with JET. We though it may be fixed when updating to version 12 (as we need to use PHP 8 instead of 7.4), but didn't fix it though.

The jet issue on version 11 is as follows:

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: system exception at 0x0000004005577e53
Please, contact the vendor of the application.
Core dump will be written to "/var/www/application/core"

Signal 11 (SIGSEGV)
siginfo: si_signo 11, si_errno 0, si_code 1, si_addr 0x000000000000002a

Version Information:

  Java version: 1.8.0_181
  Excelsior JET 15.30 Enterprise edition
  JET Profile: OpenJDK version: 1.8.0_181; JET update level: 6; CPU architecture: amd64
  Runtime: Server
  CPU features: cmov mmx sse sse2 sse3 ssse3 sse4.1 sse4.2 sse4a lzcnt popcnt bmi1 bmi2 adx cx8 cx16 movbe
  Application was deployed

Options and system properties:

  -Djet.jit.disable.resolution=
  -Djet.gc.heaplimit=0
  -Djet.stack.trace=

Entry point type: Invocation API

Command line: "php" "/var/www/application/vendor/bin/phpunit" "--configuration" "/var/www/application/phpunit.xml.dist" "/var/www/application/tests/Unit" "--teamcity"

OS:

Debian GNU/Linux 11 (bullseye)
Linux 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 x86_64
glibc 2.31

JET-compiled Components:

/opt/php/lib64/libsaxonhec.so dll, version info: jet-1530-mp1 (ent, en)

Shared libraries:
...

The code we used is this (bit dirty code as example tbh):

$saxonProcessor = $this->saxonProcessorFactory->get();
$xsltProcessor = $saxonProcessor->newXslt30Processor();

$xsltFilePath = $this->getXsltPath($xsltFileName);

$transformer = $xsltProcessor->compileFromFile($xsltFilePath);
foreach ($parameters as $key => $value) {
    $transformer->setParameter($key, $saxonProcessor->createAtomicValue($value));
}

$transformer->transformFileToFile($tmpFilePath, $outputFile->getPath());
if ($transformer->exceptionOccurred()) {
    $exception = SaxonXsltTransformException::forXslTransformation($transformer, $tmpFilePath, $xsltFilePath);
    $xsltProcessor->clearParameters();
    $xsltProcessor->exceptionClear();

    throw $exception;
}

$xsltProcessor->clearParameters();
$xsltProcessor->exceptionClear();

The issue looks the same, it somehow after some transformations stops with a SIGSEGV:

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: system exception at 0x00000040004e4204
Please, contact the vendor of the application.
Core dump will be written to "/var/www/application/core"
Extra information about error is saved in the "jet_err_1136.txt" file.
Actions #3

Updated by O'Neil Delpratt about 1 year ago

  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to Normal

Thank you for reporting this issue. I will investigate it with the repo you have sent and report back.

Actions #4

Updated by O'Neil Delpratt about 1 year ago

Is it possible you can put together a complete repro and send it over either on this bug issue or by email please.

Actions #5

Updated by O'Neil Delpratt about 1 year ago

  • Status changed from New to AwaitingInfo

Hi,

I am struggling to reproduce the failure without a repro. I have tried to construct similar PHP code but I am not seeing the crash on SaxonC 12.1.

Would a screen share be possible?

Actions #6

Updated by Youri Lefers about 1 year ago

Hi O'Neil,

I will try to put together an example somewhere this week.

Actions #7

Updated by O'Neil Delpratt 6 months ago

hi, just checking if this problem has been resolved in a later release of SaxonC 12. Did you try SaxonC 12.3?

Please register to edit this issue

Also available in: Atom PDF