You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The travis ci pipeline sometimes fails randomly on the ProcessManagerTest::testLargeBatchProcessing test. As it turns out, the unserialize function raises a notice, because of an non unserializable string, which phpunit translates into an exception. ProcessManager::fork catches this exception when calling $shm->send($message, false); and replaces the result with null.
The output of this bug is then the following:
There was 1 failure:
1) Spork\ProcessManagerTest::testLargeBatchProcessing with data set #0 (10)
null does not match expected type "array".
Background
When a new shared memory is created it may be filled with null.
shmop_read() reads and returns the whole memory segment's data. This is not useful if you're just working with strings. If you need to read a string from shared memory, call str_from_mem() on the result of shmop_read(). Similarly when writing strings to memory (instead of binary data), null terminate your strings with str_to_nts() before passing the value on to shmop_write().
As expected shmop_read returns the whole shared memory block filled with null terminators ("\x00\x00...").
Possible Fix
Before passing the shared memory contents to unserialize, make sure to truncate everything after the first null byte. Respectively add a null byte to the end of the serialized string before passing the data to shmop_write().
The text was updated successfully, but these errors were encountered:
### Changed
- #5: Preserve and restore previous signal handler. Refactored event dispatcher.
### Removed
- #5: Removed the method `addListener` from the `ProcessManager` class. Add
signal/normal listeners through the event dispatcher on the process manager.
### Fixed
- #7: Fixed missing null terminator handling on shared memory blocks.
- #8: Fixed parent's shutdown function being executed in child processes.
The travis ci pipeline sometimes fails randomly on the
ProcessManagerTest::testLargeBatchProcessing
test. As it turns out, theunserialize
function raises a notice, because of an non unserializable string, which phpunit translates into an exception.ProcessManager::fork
catches this exception when calling$shm->send($message, false);
and replaces the result withnull
.The output of this bug is then the following:
Background
When a new shared memory is created it may be filled with
null
.https://www.php.net/manual/en/function.shmop-read.php#48828
As expected
shmop_read
returns the whole shared memory block filled with null terminators ("\x00\x00..."
).Possible Fix
Before passing the shared memory contents to
unserialize
, make sure to truncate everything after the first null byte. Respectively add a null byte to the end of the serialized string before passing the data toshmop_write()
.The text was updated successfully, but these errors were encountered: