1

PHP 7.4.16 (ZTS) with parallel extension installed running Laravel 7.

ini_get('disable_functions'); returns an empty string.

I can write a script that calls setlocal(0,0) from the main process and it works without throwing an exception. This error is thrown when a library attempts to invoke it from within a parallel/Runtime thread.

        $disabled = ini_get('disable_functions');  // empty string

        //works 
        setlocale(0,0);

        $thread = new \parallel\Runtime(app_path().'/../bootstrap/parallel.php');
        $future = $thread->run(function() {
  
            $disabled = ini_get('disable_functions');  // empty string
     
            // throws setlocale() has been disabled for security reasons
            setlocale(0, 0);
        });
        var_dump([
            'value' => $future->value(),
            'cancelled' => $future->cancelled(),
            'done' => $future->done(),
        ]);

I have dumped all the ini settings, both inside a parallel\Runtime thread and outside of it. They match exactly and the function is not marked as disabled.

Is this function somehow disabled by a compile-time directive?

Jesse Skrivseth
  • 481
  • 2
  • 13

1 Answers1

0

The problem here was in my bootstrap / autoload function. It was doing this

<?php
require __DIR__ . '/autoload.php';
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__.'/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;

\Illuminate\Contracts\Console\Kernel->bootstrap() somehow breaks setlocale(), even though it's not setting ini_set(). I have not stepped through it in debug to know for sure yet.

The working bootstrap code is

<?php
require __DIR__ . '/autoload.php';
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__.'/app.php';
$app->register(\App\Providers\AppServiceProvider::class)
    ->runningInThread(true);
return $app;
Jesse Skrivseth
  • 481
  • 2
  • 13