Segmentation fault when enable PDO::ATTR_PERSISTENT
razonyang opened this issue · 1 comments
If you know how to write phpt tests, please open a PR with environment information, and your test, this will cause CI to test your issue before a human is able to look
Environment
$ php72 -v
PHP 7.2.12 (cli) (built: Nov 29 2018 14:57:26) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
$ php72 -dextension=pthreads.so --ri pthreads | grep Version
PHP Warning: Module 'pthreads' already loaded in Unknown on line 0
Version => 3.1.7dev
OS: Linux, Deepin
- PHP: can be obtained with
php -v
- pthreads: can be obtained with
php -dextension=pthreads.so --ri pthreads | grep Version
- OS: if Windows, include arch
Summary
A summary isn't always necessary, code > words ... delete this section, as applicable.
Reproducing Code
<?php
$threads = [];
$threadsCount = 2;
for ($i = 0; $i < $threadsCount; $i++) {
$thread = new MyThread();
$threads[] = $thread;
$thread->start();
}
foreach ($threads as $thread) {
$thread->join();
}
class MyThread extends \Thread
{
public function run()
{
for ($j = 0; $j < 3; $j++) {
$conn = new PDO('mysql:host=127.0.0.1', 'root', '', [
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
}
}
}
Bug reports must come with reproducing code, please ensure code is formatted correctly.
If the code cannot be a single script, please link to a gist, or a github repository containing the reproducing code.
Please, do not link to application repositories.
Please ensure code is self contained, and executable: if the code cannot be executed, the bug cannot be reproduced.
Expected Output
Please include the expected output, properly formatted.
Actual Output
Segmentation fault
Please include the actual output, properly formatted.
This is related to PDO and not yet fixable in pthreads. I can only recommend to avoid persistent connections.