-
-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.12.8] Segfault on Phalcon #1941
Comments
|
@dreamsxin Do you have any idea? |
@ruudboon Can you provide a single file to reproduce the bug by any chance? P.S.
Also could you disable xdebug and test again? |
@sergeyklay you mean a single Zephir file? Single php file is in the updated issue. |
Yes, a single |
Occurs without xdebug as well. |
Could you please provide at least working test so that I'll try to reproduce the issue myself |
I will test |
|
@dreamsxin Try this use Phalcon\Acl\Adapter\Memory;
use Phalcon\Acl\RoleAware;
use Phalcon\Di;
use Phalcon\Di\DiInterface;
use Phalcon\Events\Event;
use Phalcon\Firewall\Adapter\Acl;
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Firewall\Exception;
class PeopleController extends Controller {}
class RoleObject implements RoleAware {
public function getRoleName(): string {
return 'myrole';
}
}
$container = new Di();
$container->set('myrole', new RoleObject);
$acl = new Memory();
$acl->addComponent('app', ['allow-all']);
$acl->addRole('myrole');
$acl->allow('myrole', 'app', 'allow-all');
$container->set('acl', $acl);
$dispatcher = new Dispatcher();
$dispatcher->setDI($container);
$reflection = new \ReflectionClass($dispatcher);
$activeHandler = $reflection->getProperty('activeHandler');
$activeHandler->setAccessible(true);
$activeHandler->setValue($dispatcher, new PeopleController);
$source = new stdClass();
$data = [1, 2, 3];
$event = new Event("test", $source, $data, false);
$firewall = new Acl('acl');
$firewall->setRoleCallback(
function (DiInterface $container) {
return $container->get('myrole');
}
);
try {
$firewall->beforeExecuteRoute($event, $dispatcher, "");
} catch (Exception $e) {
// Expected
fprintf(STDERR, $e->getMessage() . PHP_EOL);
exit(0);
}
exit(1);
|
Return this change back solves this issue: diff --git a/kernels/ZendEngine3/operators.h b/kernels/ZendEngine3/operators.h
index 78daf75e..3ec3ca14 100644
--- a/kernels/ZendEngine3/operators.h
+++ b/kernels/ZendEngine3/operators.h
@@ -223,8 +223,8 @@ long zephir_safe_mod_double_zval(double op1, zval *op2);
if (Z_TYPE_P(passValue) == IS_ARRAY) { \
ZEPHIR_CPY_WRT(returnValue, passValue); \
} else { \
- convert_to_array(passValue); \
- ZEPHIR_CPY_WRT(returnValue, passValue); \
+ ZEPHIR_INIT_NVAR(returnValue); \
+ array_init_size(returnValue, 0); \
} \
} See: a6c9d0c /cc @chrysanthemum |
This may be considered as a fix diff --git a/kernels/ZendEngine3/operators.h b/kernels/ZendEngine3/operators.h
index 78daf75e..401ab5fa 100644
--- a/kernels/ZendEngine3/operators.h
+++ b/kernels/ZendEngine3/operators.h
@@ -222,7 +222,10 @@ long zephir_safe_mod_double_zval(double op1, zval *op2);
{ \
if (Z_TYPE_P(passValue) == IS_ARRAY) { \
ZEPHIR_CPY_WRT(returnValue, passValue); \
- } else { \
+ } else if (Z_ISNULL_P(passValue) || Z_ISUNDEF_P(passValue)) { \
+ ZEPHIR_INIT_NVAR(returnValue); \
+ array_init_size(returnValue, 0); \
+ } else { \
convert_to_array(passValue); \
ZEPHIR_CPY_WRT(returnValue, passValue); \
} \ but there is another issue using the PHP script I provided above ^
|
The code to reproduce the issue after these changes #1941 (comment): // file "manual.php"
$container = new Phalcon\Di();
$container->set('abcde', new stdClass); $ php -d extension=ext/modules/phalcon.so manual.php
[Sat Oct 5 17:23:07 2019] Script: '/mnt/work/phalcon/cphalcon/manual.php'
/home/klay/src/php/source/7.2.20/Zend/zend_objects.c(161) : Freeing 0x00007f2724470100 (88 bytes), script=/mnt/work/phalcon/cphalcon/manual.php
=== Total 1 memory leaks detected ===
[1] 22006 segmentation fault php -d extension=ext/modules/phalcon.so manual.php
|
Fixed in the N.B. There is another issue, leads to segfault (introduced in 11dc1d4) I'll fix in next commits. |
Refs: - #1941 (comment) - 11dc1d4 /cc @dreamsxin
When running:
I get a segfault with this backtrace
The text was updated successfully, but these errors were encountered: