Segmentation fault - for almost everything
[Backstory - SKIP if not interrested] I have a PHP 7.4.3 environment with Yii2 and mongoDB on Windows and now also on centos 7.7 with parallel. First I used parallel to create a customized HunSpell php wrapper, and it worked perfectly and the performance was great. Then I decided to change the existing worker manager to not use multiprocessing but multithreading with the parallel instead, so I could spare some memory with it and I would have a new much superior design then the old one. But I run into segmentation fault almost with everything.
[Setup] Well I use closures and store some functions in it, then later I call them with parameters. Example:
$this->dbQueryClosure = static function ($taskQueue, $mode) {
// reference point 1.
new Autoloader($mode);
// reference point 2.
return BaseTask::findAll([
'status' => BaseTask::STATUS_PENDING
]);
// Reference point 3.
return (new ThreadedExecutionManagerSearch())->search(['taskQueue' => $taskQueue])->getModels();
};
This it how I call it:
$schedulerQueryResults = $this->dbQueryThread->run($this->dbQueryClosure, [$this->taskQueue, $this->mode]);
This is actually in an infinite loop, but I only overwrite the Future when it's value becomes null + X seconds are passing(long enough) - I'm clearing the Future after it's passed to other variable - I wanted something like an interruption design, so I made this query thread for that and in parallel I would like to listen to UPD/unix socket + execute the tasks. I'm also not calling the run function on the Runtime, untill the previous is finished.
[Issues] As we know it's possible to pass an autoloader to the Runtime constructor, like:
$this->dbQueryThread = (new Runtime(Yii::$app->params['taskManager']['bootstrapFile']));
(1)But if there is an out of scope issue, then I don't get proper error message, but a segmentation fault without any error messages, which was kinda fustrating to find out what is really going on. Then, when I tried to pass some Yii::$app property variables to the closure, I faced with the same issue. No proper error message, just a crash. So even if I would like to build a logic to handle the runtime errors I can't do anything, because it will just crash the php-cli, and that's it.
(2)At ref point 2, it's just crashes, when I'm using active record. I dont really know if it's a scoping issue or not. In theory its not, because the class is loaded at that point - I checked it - and again I dont have any other idea, because there is no error message, just a crash.
(3)at ref point 3; surprisingly this part is running. That class contains a mongodb query, which returns with a simple array. However, when I would like to create an object, like;
$task = new <randomTaskName>()
$task->setAttributes($variablesFromTheArray);
then again; crash and no error message - classes are also loaded.
[Note] First I thought that the issue will be the windows environment, but then I moved the project to a centos, and it was the same, so it's not OS related.
[Questions] Somehow there are just way too many problems with this extension, which makes me think that it's because of it's maybe not supporting php 7.4? Can it be a problem? or is there any other reason I dont know about?
Is there anything I can do or is it better to leave this extension out of the project? Because of the crashes without error messages are too critical to go to production - not to mention that I can't even get that far with the currect situations.
Thanks!
make test result:
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 45
---------------------------------------------------------------------
Number of tests : 124 124
Tests skipped : 0 ( 0.0%) --------
Tests warned : 5 ( 4.0%) ( 4.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Tests passed : 119 ( 96.0%) ( 96.0%)
---------------------------------------------------------------------
Time taken : 8 seconds
=====================================================================
=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
parallel cancellation (not running) [tests/base/045.phpt] (warn: XLEAK section but test passes)
parallel cancellation (running) [tests/base/046.phpt] (warn: XLEAK section but test passes)
parallel cancellation (already cancelled) [tests/base/048.phpt] (warn: XLEAK section but test passes)
parallel cancellation (runtime killed) [tests/base/049.phpt] (warn: XLEAK section but test passes)
parallel cancellation (value on cancelled) [tests/base/050.phpt] (warn: XLEAK section but test passes)
=====================================================================
Unlimited ram and/or disabling the zend_opcache is not helping. PHP version:
PHP 7.4.3 (cli) (built: Mar 25 2020 13:44:33) ( ZTS )
loaded modules:
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mongodb
openssl
parallel
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
I'd suggest running PHP with parallel inside of gdb so you can capture a stack trace when the segfault occurs.
Thanks for the response! I recompiled the PHP 7.4.3 with --enable-debug, also did the same with 7.4.4 on both centos and windows environments. I got an extra error above the expected ones. Then I compiled the recompiled the parallel and there was one test failing:
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 45
---------------------------------------------------------------------
Number of tests : 124 124
Tests skipped : 0 ( 0.0%) --------
Tests warned : 5 ( 4.0%) ( 4.0%)
Tests failed : 1 ( 0.8%) ( 0.8%)
Tests passed : 118 ( 95.2%) ( 95.2%)
---------------------------------------------------------------------
Time taken : 12 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Check sync get/set [tests/sync/002.phpt]
=====================================================================
=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
parallel cancellation (not running) [tests/base/045.phpt] (warn: XLEAK section but test passes)
parallel cancellation (running) [tests/base/046.phpt] (warn: XLEAK section but test passes)
parallel cancellation (already cancelled) [tests/base/048.phpt] (warn: XLEAK section but test passes)
parallel cancellation (runtime killed) [tests/base/049.phpt] (warn: XLEAK section but test passes)
parallel cancellation (value on cancelled) [tests/base/050.phpt] (warn: XLEAK section but test passes)
=====================================================================
I also got a failing test for the mongodb module. I think none of these were failing in the non debug environment.
Anyway, running the test after that resulted with this output:
php: /home/synida/php-src-php-7.4.3/Zend/zend_types.h:1039: zend_gc_delref: Assertion `p->refcount > 0' failed.
Aborted
But I think it was crashing on something different then before - like much earlier.
I also tried to get a backtrace with the gdb using the descriptions from here, but since I dont have previous experience in using this tool and the description is kinda poor, I didn't have a success with it so far.
gdb path/to/your/php
then inside gdb shell:
run path/to/your/php/script.php
when the process segfaults, type bt to see the backtrace.
Thanks for the help again, honestly! This is the output I got:
(gdb) bt
#0 0x00007ffff1996337 in raise () from /lib64/libc.so.6
#1 0x00007ffff1997a28 in abort () from /lib64/libc.so.6
#2 0x00007ffff198f156 in __assert_fail_base () from /lib64/libc.so.6
#3 0x00007ffff198f202 in __assert_fail () from /lib64/libc.so.6
#4 0x0000000000961c68 in zend_gc_delref (p=0x7fffe582d340) at /home/synida/php-src-php-7.4.3/Zend/zend_types.h:1039
#5 0x0000000000961f0a in i_zval_ptr_dtor (zval_ptr=0x7fffe55545c0) at /home/synida/php-src-php-7.4.3/Zend/zend_variables.h:43
#6 0x0000000000962127 in zval_ptr_dtor (zval_ptr=0x7fffe55545c0) at /home/synida/php-src-php-7.4.3/Zend/zend_variables.c:84
#7 0x000000000097ca67 in _zend_hash_str_add_or_update_i (ht=0x7fffe581a360, str=0x7fffe7bc09a7 "mode", len=4, h=9223372043240258122,
pData=0x7fffffff8fc0, flag=1) at /home/synida/php-src-php-7.4.3/Zend/zend_hash.c:834
#8 0x000000000097ce75 in zend_hash_str_update (ht=0x7fffe581a360, str=0x7fffe7bc09a7 "mode", len=4, pData=0x7fffffff8fc0)
at /home/synida/php-src-php-7.4.3/Zend/zend_hash.c:910
#9 0x00007fffe7b954ec in php_phongo_readpreference_get_properties_hash (object=0x7fffffff90b0, is_debug=false)
at /home/synida/mongo-php-driver/src/MongoDB/ReadPreference.c:416
#10 0x00007fffe7b95825 in php_phongo_readpreference_get_properties (object=0x7fffffff90b0)
at /home/synida/mongo-php-driver/src/MongoDB/ReadPreference.c:556
#11 0x00000000009ba49f in zend_std_get_gc (object=0x7fffffff90b0, table=0x7fffffff90c8, n=0x7fffffff90d4)
at /home/synida/php-src-php-7.4.3/Zend/zend_object_handlers.c:123
#12 0x000000000099fa62 in gc_scan_black (ref=0x7fffe54ea8b0, stack=0x7fffe530e000) at /home/synida/php-src-php-7.4.3/Zend/zend_gc.c:708
#13 0x00000000009a0728 in gc_scan (ref=0x7fffe5a3ad80, stack=0x7fffffff9200) at /home/synida/php-src-php-7.4.3/Zend/zend_gc.c:1001
#14 0x00000000009a0c66 in gc_scan_roots (stack=0x7fffffff9200) at /home/synida/php-src-php-7.4.3/Zend/zend_gc.c:1122
#15 0x00000000009a196a in zend_gc_collect_cycles () at /home/synida/php-src-php-7.4.3/Zend/zend_gc.c:1454
#16 0x0000000000984b06 in zif_gc_collect_cycles (execute_data=0x7fffee618f20, return_value=0x7fffffffa280)
at /home/synida/php-src-php-7.4.3/Zend/zend_builtin_functions.c:375
#17 0x00000000009dcbe9 in ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_UNUSED_HANDLER () at /home/synida/php-src-php-7.4.3/Zend/zend_vm_execute.h:1442
#18 0x0000000000a41ff3 in execute_ex (ex=0x7fffee614020) at /home/synida/php-src-php-7.4.3/Zend/zend_vm_execute.h:53809
#19 0x0000000000a4615c in zend_execute (op_array=0x7fffee687300, return_value=0x0) at /home/synida/php-src-php-7.4.3/Zend/zend_vm_execute.h:57913
#20 0x0000000000967764 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/synida/php-src-php-7.4.3/Zend/zend.c:1665
#21 0x00000000008b308e in php_execute_script (primary_file=0x7fffffffd8e0) at /home/synida/php-src-php-7.4.3/main/main.c:2617
#22 0x0000000000a48b75 in do_cli (argc=7, argv=0x162a760) at /home/synida/php-src-php-7.4.3/sapi/cli/php_cli.c:961
#23 0x0000000000a49cc5 in main (argc=7, argv=0x162a760) at /home/synida/php-src-php-7.4.3/sapi/cli/php_cli.c:1356
This is not the issue with the parallel - Imo - because the test is failing around the start - not like in the non-debug version. So I think I could get that error message, if I could pass this error somehow - and if there aren't more of them in between, cuz of the debug version. (Maybe I did something wrong, which lead me to this extra error?)
#4 0x0000000000961c68 in zend_gc_delref (p=0x7fffe582d340) at /home/synida/php-src-php-7.4.3/Zend/zend_types.h:1039
Here actually I have this:
static zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) {
// This next line isn't in the original source, I'm just kinda tried to fix it locally, but it didn't work
if (p->refcount == 0) return p->refcount;
ZEND_ASSERT(p->refcount > 0);
ZEND_RC_MOD_CHECK(p);
return --(p->refcount);
}
Okay actually I returned with 0 where the ZEND_ASSERT(p->refcount > 0) failed if the refcount is 0, just to see the parallel error, which I could get like this. I cant copy all of the backtrace here, because it's kinda huge and it seems like I run out of memory - seemingly because of an infinite loop:
(gdb) bt
#0 0x00007ffff19e2491 in _int_malloc () from /lib64/libc.so.6
#1 0x00007ffff19e5adc in malloc () from /lib64/libc.so.6
#2 0x000000000092ada1 in __zend_malloc (len=56) at /home/synida/php-src-php-7.4.4/Zend/zend_alloc.c:2976
#3 0x00007fffe788bc2b in php_parallel_copy_mem (source=0x7fffe4145f60, size=56, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.h:63
#4 0x00007fffe788c667 in php_parallel_copy_mem_persistent (source=0x7fffe4145f60, size=56) at /home/synida/parallel-1.1.3/src/copy.c:293
#5 0x00007fffe788c133 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:175
#6 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302
#7 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe066c2c8, source=0x7fffe4159b68, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:809
#8 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676
#9 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747
#10 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066c1f8, source=0x7fffe40d8c28, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:813
#11 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe40d8c00) at /home/synida/parallel-1.1.3/src/copy.c:676
#12 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe40d8c00, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747
#13 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066c188, source=0x7fffe066c188, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:813
#14 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe066c188, source=0x7fffe066c188,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:167
#15 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe40fa840,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#16 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe40fa840,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313
#17 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066c0f8, source=0x7fffe066c0f8,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149
#18 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145d80,
---Type <return> to continue, or q <return> to quit---
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#19 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4145d80,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313
#20 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066c088, source=0x7fffe066c088,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149
#21 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114000,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#22 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4114000,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313
#23 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066bff0, source=0x7fffe066bff0,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149
#24 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60,
php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>,
php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#25 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302
#26 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe066bea8, source=0x7fffe4159b68, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:809
#27 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676
#28 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747
#29 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066bdd8, source=0x7fffe40d8c28, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:813
#30 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe40d8c00) at /home/synida/parallel-1.1.3/src/copy.c:676
#31 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe40d8c00, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747
#32 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066bd68, source=0x7fffe066bd68, persistent=1 '\001')
at /home/synida/parallel-1.1.3/src/copy.c:813
#33 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe066bd68, source=0x7fffe066bd68,
---Type <return> to continue, or q <return> to quit---
... some thousand more lines here ....
I turned of the pagination for the bt here just to see the first part, because it's might be also interresting, and hiding some information, we can use:
#107029 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#107030 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313
#107031 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe00bca10, source=0x7fffe00bca10, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149
#107032 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#107033 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302
#107034 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe00bc158, source=0x7fffe4159b68, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809
#107035 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676
#107036 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747
#107037 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe00bc7f8, source=0x7fffe00bc7f8, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813
#107038 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe00bc7f8, source=0x7fffe00bc7f8, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:167
#107039 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114180, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219
#107040 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4114180, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302
#107041 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe5155168, source=0x7fffe4ffec10, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809
#107042 0x00007fffe7889bbf in php_parallel_scheduler_run (runtime=0x7fffe51d1840, frame=0x7fffe4417020) at /home/synida/parallel-1.1.3/src/scheduler.c:287
#107043 0x00007fffe788a094 in php_parallel_thread (arg=0x7fffe51d1840) at /home/synida/parallel-1.1.3/src/scheduler.c:437
#107044 0x00007ffff64bae65 in start_thread () from /lib64/libpthread.so.0
#107045 0x00007ffff1a5e88d in clone () from /lib64/libc.so.6
Hopefully it's not a different error from what I should expect to get, because of the one liner change I made in that header above.
Actually I do have a seemingly infinite loop:
// executing the run function of the Runtime class which is a protected variable of the service class($taskManager)
// $queryThread is the where I put the Future class
$taskManager->startScheduledQuery($queryThread);
// this loop should be tested like this because of the similar functionality of the implementation
while (1) {
// if the Future is not null and done then get the result and exit the loop
if ($queryThread !== null && $queryThread->done()) {
$result = $queryThread->value();
break;
}
}
However it's working correctly if I dont put in this:
// reference point 2.
return BaseTask::findAll([
'status' => BaseTask::STATUS_PENDING
]);
part into the closure as I mentioned above in the first comment.
This previous out of memory case happens only if the I run the codeception with the debugger mode. If I use it without the debug option, then I got this error in the gdb:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe4fff700 (LWP 24488)]
0x0000000000960cb8 in instanceof_class (instance_ce=0xa0, ce=0x7fffe45ac980) at /home/synida/php-src-php-7.4.4/Zend/zend_operators.c:2318
2318 instance_ce = instance_ce->parent;
(gdb) bt
#0 0x0000000000960cb8 in instanceof_class (instance_ce=0xa0, ce=0x7fffe45ac980) at /home/synida/php-src-php-7.4.4/Zend/zend_operators.c:2318
#1 0x0000000000960e4e in instanceof_function (instance_ce=0x7fffe5155150, ce=0x7fffe45ac980)
at /home/synida/php-src-php-7.4.4/Zend/zend_operators.c:2358
#2 0x0000000000762bb6 in zif_spl_autoload_call (execute_data=0x7fffe4417110, return_value=0x7fffe4ffe7d0)
at /home/synida/php-src-php-7.4.4/ext/spl/php_spl.c:441
#3 0x000000000094ef35 in zend_call_function (fci=0x7fffe4ffe790, fci_cache=0x7fffe4ffe770)
at /home/synida/php-src-php-7.4.4/Zend/zend_execute_API.c:825
#4 0x000000000094f96a in zend_lookup_class_ex (name=0x1904710, key=0x1904750, flags=512)
at /home/synida/php-src-php-7.4.4/Zend/zend_execute_API.c:994
#5 0x00000000009506ec in zend_fetch_class_by_name (class_name=0x1904710, key=0x1904750, fetch_type=512)
at /home/synida/php-src-php-7.4.4/Zend/zend_execute_API.c:1425
#6 0x00000000009eeeeb in ZEND_NEW_SPEC_CONST_UNUSED_HANDLER () at /home/synida/php-src-php-7.4.4/Zend/zend_vm_execute.h:9205
#7 0x0000000000a44b56 in execute_ex (ex=0x7fffe4417020) at /home/synida/php-src-php-7.4.4/Zend/zend_vm_execute.h:54571
#8 0x00007fffe7889a0a in php_parallel_scheduler_run (runtime=0x7fffe51d1840, frame=0x7fffe4417020)
at /home/synida/parallel-1.1.3/src/scheduler.c:261
#9 0x00007fffe788a094 in php_parallel_thread (arg=0x7fffe51d1840) at /home/synida/parallel-1.1.3/src/scheduler.c:437
#10 0x00007ffff64bae65 in start_thread () from /lib64/libpthread.so.0
#11 0x00007ffff1a5e88d in clone () from /lib64/libc.so.6
A bit later I dissabled the zend opcache module, and I got back the previous out of memory error
This problem occures when the object you are using inside of a thread has a TimestampBehavior class set, which is part of the Yii framework, similarly it happens if there is any other behaviour class used.
Okay actually I returned with 0 where the ZEND_ASSERT(p->refcount > 0) failed if the refcount is 0, just to see the parallel error, which I could get like this. I cant copy all of the backtrace here, because it's kinda huge and it seems like I run out of memory - seemingly because of an infinite loop:
(gdb) bt #0 0x00007ffff19e2491 in _int_malloc () from /lib64/libc.so.6 #1 0x00007ffff19e5adc in malloc () from /lib64/libc.so.6 #2 0x000000000092ada1 in __zend_malloc (len=56) at /home/synida/php-src-php-7.4.4/Zend/zend_alloc.c:2976 #3 0x00007fffe788bc2b in php_parallel_copy_mem (source=0x7fffe4145f60, size=56, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.h:63 #4 0x00007fffe788c667 in php_parallel_copy_mem_persistent (source=0x7fffe4145f60, size=56) at /home/synida/parallel-1.1.3/src/copy.c:293 #5 0x00007fffe788c133 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:175 #6 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302 #7 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe066c2c8, source=0x7fffe4159b68, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809 #8 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676 #9 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747 #10 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066c1f8, source=0x7fffe40d8c28, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813 #11 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe40d8c00) at /home/synida/parallel-1.1.3/src/copy.c:676 #12 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe40d8c00, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747 #13 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066c188, source=0x7fffe066c188, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813 #14 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe066c188, source=0x7fffe066c188, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:167 #15 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe40fa840, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #16 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe40fa840, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313 #17 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066c0f8, source=0x7fffe066c0f8, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149 #18 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145d80, ---Type <return> to continue, or q <return> to quit--- php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #19 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4145d80, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313 #20 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066c088, source=0x7fffe066c088, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149 #21 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #22 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313 #23 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe066bff0, source=0x7fffe066bff0, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149 #24 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #25 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302 #26 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe066bea8, source=0x7fffe4159b68, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809 #27 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676 #28 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747 #29 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066bdd8, source=0x7fffe40d8c28, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813 #30 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe40d8c00) at /home/synida/parallel-1.1.3/src/copy.c:676 #31 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe40d8c00, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747 #32 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe066bd68, source=0x7fffe066bd68, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813 #33 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe066bd68, source=0x7fffe066bd68, ---Type <return> to continue, or q <return> to quit--- ... some thousand more lines here .... I turned of the pagination for the bt here just to see the first part, because it's might be also interresting, and hiding some information, we can use: #107029 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #107030 0x00007fffe788c6f4 in php_parallel_copy_hash_persistent (source=0x7fffe4114000, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:313 #107031 0x00007fffe788bfd2 in php_parallel_copy_zval_persistent (dest=0x7fffe00bca10, source=0x7fffe00bca10, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:149 #107032 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4145f60, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #107033 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4145f60, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302 #107034 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe00bc158, source=0x7fffe4159b68, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809 #107035 0x00007fffe788d330 in php_parallel_copy_object_persistent (source=0x7fffe4159b40) at /home/synida/parallel-1.1.3/src/copy.c:676 #107036 0x00007fffe788d582 in php_parallel_copy_object_ctor (source=0x7fffe4159b40, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:747 #107037 0x00007fffe788d7f9 in php_parallel_copy_zval_ctor (dest=0x7fffe00bc7f8, source=0x7fffe00bc7f8, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:813 #107038 0x00007fffe788c10b in php_parallel_copy_zval_persistent (dest=0x7fffe00bc7f8, source=0x7fffe00bc7f8, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:167 #107039 0x00007fffe788c327 in php_parallel_copy_hash_persistent_inline (source=0x7fffe4114180, php_parallel_copy_string_func=0x7fffe788c669 <php_parallel_copy_string_persistent>, php_parallel_copy_memory_func=0x7fffe788c63f <php_parallel_copy_mem_persistent>) at /home/synida/parallel-1.1.3/src/copy.c:219 #107040 0x00007fffe788c6b9 in php_parallel_copy_hash_ctor (source=0x7fffe4114180, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:302 #107041 0x00007fffe788d7bd in php_parallel_copy_zval_ctor (dest=0x7fffe5155168, source=0x7fffe4ffec10, persistent=1 '\001') at /home/synida/parallel-1.1.3/src/copy.c:809 #107042 0x00007fffe7889bbf in php_parallel_scheduler_run (runtime=0x7fffe51d1840, frame=0x7fffe4417020) at /home/synida/parallel-1.1.3/src/scheduler.c:287 #107043 0x00007fffe788a094 in php_parallel_thread (arg=0x7fffe51d1840) at /home/synida/parallel-1.1.3/src/scheduler.c:437 #107044 0x00007ffff64bae65 in start_thread () from /lib64/libpthread.so.0 #107045 0x00007ffff1a5e88d in clone () from /lib64/libc.so.6Hopefully it's not a different error from what I should expect to get, because of the one liner change I made in that header above.
Actually I do have a seemingly infinite loop:
// executing the run function of the Runtime class which is a protected variable of the service class($taskManager) // $queryThread is the where I put the Future class $taskManager->startScheduledQuery($queryThread); // this loop should be tested like this because of the similar functionality of the implementation while (1) { // if the Future is not null and done then get the result and exit the loop if ($queryThread !== null && $queryThread->done()) { $result = $queryThread->value(); break; } }However it's working correctly if I dont put in this:
// reference point 2. return BaseTask::findAll([ 'status' => BaseTask::STATUS_PENDING ]);part into the closure as I mentioned above in the first comment.
This is a result of recursion that is at the moment unsupported by parallel, other issues exist about it ...
It's on my list ...
Fixed in 67413b193ecda80a32335a76eb25454a4d54bb32