Skip to content

Process termination when attempting to access object #269

Description

@pwoo

After spending a few hours debugging through native code that worked on PHP 5.6 (and PHP-CPP legacy), it looks like the recent 2.0.0 release is not playing nice when objects are passed in.

I've managed to whittle down the problem to what essentially looks like an issue with accessing PHP objects.

Example:

#include <phpcpp.h>
#include <iostream>
void test(Php::Parameters &params)
{       
    Php::Value obj = params[0]; 
    std::cout << obj["test"] << std::endl;
}

extern "C" {
    PHPCPP_EXPORT void *get_module() {
        static Php::Extension extension("php_cpp", "1.0");
        extension.add<test>("test", { 
            Php::ByRef("obj",` Php::Type::Null, false);
        });
        return extension;
    }
}

And then a test script to confirm:

$foo = new stdClass;
$foo->test = 23;
test($foo);

Results in a segfault. Passing $foo = ['test' => 23] (as an array) to the function has no issues.

Tested on PHP-CLI 7.0.12. The header file being used reported by php-config also matches this version, so I do not believe there were any compilation issues when building 2.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions