Skip to content

502 Bad Gateway (Segmentation fault when using array_walk_recursive) #246

@several27

Description

@several27

Hi,
I'm getting 502 Bad Gateway with the following error in error.log
2016/07/13 14:53:24 [error] 769#769: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream

This is the code that I'm trying to execute:

Route::get('v8js', function () {
    $data = SomeLaravelModel::find(10)->first()->toArray();

    $v8            = new V8Js();
    $v8->some_data = $data;
    $v8->executeString('print(JSON.stringify(PHP));');
});

I have installed v8 version 5.1.99 (as the newest is not compiling properly) with the newest version of homestead and laravel. I'm using php7 and also v8js from php7 branch.

Most of the time it works perfectly fine, but for some unknown reason the code above is not working.

What's even more interesting: if I replace the line where I assign $data to some_data with:

    $v8->questionnairee = \unserialize(\serialize($data));

it works as expected.

Edit:
Relevant log line from the syslog:

Jul 18 10:27:42 homestead kernel: [ 9676.279356] php-fpm7.0[4581]: segfault at 0 ip 00007f07ecff8b13 sp 00007ffdf2fbcc50 error 4 in libv8.so[7f07ec955000+bb5000]

Edit 2:
Apparently its a more generic issue not related to laravel.
The code below is responsible for segmentation fault above:

$v8 = new V8Js();
$array = ['lorem' => 'ipsum'];
array_walk_recursive($array, function (&$item) {});
$v8->some_array = $array;

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