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?

Please register to edit this issue

Also available in: Atom PDF