amabnl / amadeus-ws-client

PHP Amadeus SOAP Web Service client library
Apache License 2.0
178 stars 191 forks source link

Segmentation Fault on PNR_Retrieve #352

Open mersinvald opened 5 years ago

mersinvald commented 5 years ago

Hello, I am trying to use this library and I have encountered a segfault originating in PHP Soap extension.

PHP Version: tried every version readily available in Ubuntu 18.04 repository, both 7. and 5.. OS: Mac OS & Ubuntu 18.04

Code snippet (basically the example from this repo):

<?php
require 'vendor/autoload.php';
use Amadeus\Client;
use Amadeus\Client\Params;
use Amadeus\Client\Result;
use Amadeus\Client\RequestOptions\PnrRetrieveOptions;

//Set up the client with necessary parameters:

$params = new Params([
    'authParams' => [
        'officeId' => 'OFFICE_ID', //The Amadeus Office Id you want to sign in to - must be open on your WSAP.
        'userId' => 'USER_ID', //Also known as 'Originator' for Soap Header 1 & 2 WSDL's
        'passwordData' => 'cGFzc3dvcmQK' // **base 64 encoded** password
    ],
    'sessionHandlerParams' => [
        'soapHeaderVersion' => Client::HEADER_V4, //This is the default value, can be omitted.
        'wsdl' => 'my_wsdl.wsdl', //Points to the location of the WSDL file containing the PNR_Retrieve method.
        'stateful' => false, //Enable stateful messages by default - can be changed at will to switch between stateless & stateful.
        'logger' => new Psr\Log\NullLogger()
    ],
    'requestCreatorParams' => [
        'receivedFrom' => 'my test project' // The "Received From" string that will be visible in PNR History
    ]
]);

print("Params created!\n");

$client = new Client($params);

print("Client created!\n");

// segfault happens here
$pnrResult = $client->pnrRetrieve(
    new PnrRetrieveOptions(['recordLocator' => 'ABC123'])
);

print("PNR Retrieved!\n");

if ($pnrResult->status === Result::STATUS_OK) {
    echo "Successfully retrieved PNR, no errors in PNR found!";
    echo "PNR XML string received: <pre>" . $pnrResult->responseXml . "</pre>";
}

GDB backtrace:

Starting program: /usr/bin/php main.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Params created!
Client created!

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
62  ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory.
(gdb) bt
#0  __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
#1  0x00007fffef6bde89 in ?? () from /usr/lib/php/20190529/soap.so
#2  0x00007fffef6be16f in ?? () from /usr/lib/php/20190529/soap.so
#3  0x00007fffef6be623 in ?? () from /usr/lib/php/20190529/soap.so
#4  0x00007fffef6bfd63 in ?? () from /usr/lib/php/20190529/soap.so
#5  0x00007fffef6965ef in ?? () from /usr/lib/php/20190529/soap.so
#6  0x00005555558752ed in execute_ex ()
#7  0x00005555558763e2 in zend_execute ()
#8  0x00005555557e8ec2 in zend_execute_scripts ()
#9  0x00005555557882b0 in php_execute_script ()
#10 0x0000555555878374 in ?? ()
#11 0x000055555564309b in ?? ()
#12 0x00007ffff5c20b97 in __libc_start_main (main=0x555555642c80, argc=2, argv=0x7fffffffe068, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe058) at ../csu/libc-start.c:310
#13 0x000055555564323a in _start ()
therealartz commented 5 years ago

Could you show source xml request and response?

mersinvald commented 5 years ago

@therealartz can you show me how I can get those? I'm not a PHP developer, just trying to run the examples.

therealartz commented 5 years ago

Actually your error looks like php error, not this library at all. And there missing strlen compiled files. I guess it's something wrong with your installation of php

mersinvald commented 5 years ago

@therealartz that is quite weird, as I tried different versions on different operation systems, as well as the other person I asked tried it on Windows with the same segmentation fault.

strlen files aren't missing, it's a libc function, there just isn't any debuginfo in the libc (which is normal with the release build of libc on any modern OS). Missing file isn't an execution error, it's the gdb error, it says that it can't find debuginfo to show.

What this stacktrace actually says is that something is causing the misuse of php soap plug-in, which, in turn, uses the strlen function incorrectly, leading to a segmentation fault.

bimusiek commented 4 years ago

@mersinvald Did you try to run some example soap function directly to see if the issue is with library or with your php installation?

For me looks like an issue with PHP installation, as we are using this library for some time on dockerized containers and have no issues whatsoever.