在symfony 3

时间:2018-10-14 10:06:00

标签: symfony redis phpspreadsheet

我遇到了一个奇怪的问题。我使用phpoffice/phpspreadsheet软件包解析Symvony 3的csv和excel,最近,我按照推荐的here设置了Redis缓存:

$client = new \Redis();
$client->connect('127.0.0.1', 6379);
$pool = new \Cache\Adapter\Redis\RedisCachePool($client);
$simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);

\PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);

它确实有效,我的速度提高了2倍。但是,运行测试时出现问题。除一张外,所有通行证。它有@dataProvider。而且它在第六指数上失败了。重要提示:它不依赖于@dataProvider中提供的条目数据。我以不同的方式更改了参数。我什至复制了它们。因此,即使所有参数都相同,第6个参数也会失败。错误为Segmentation fault

经过一些调试后,我发现了问题。错误是由this line函数“ unserialize”引起的。对我来说很奇怪。

测试通过且没有redis缓存。因此它以某种方式连接到Redis。但是甚至找不到unserialize的参数中包含“ redis”或“ phpspreadsheet”的字符串(调试时得到了该参数)。

我不知道发生了什么。在失败的测试用例中,即使内核没有启动,我也与测试中的代码无关。

更新

我尝试通过strace获取更多信息。这是该命令的最后几行:

read(25, "ContainerBuilderDebugDumpPass.php\";}i:65;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":130:{s:121:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php\";}i:66;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":124:{s:115:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ConfigCachePass.php\";}i:67;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":129:{s:120:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php\";}i:68;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":117:{s:108:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php\";}i:69;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":123:{s:114:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigEnvironmentPass.php\";}i:70;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":118:{s:109:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php\";}i:71;C:46:\"Symfony\\Component\\Conf"..., 8192) = 8192
read(25, "source\":123:{s:114:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php\";}i:157;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":122:{s:113:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php\";}i:164;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":120:{s:111:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php\";}i:165;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":130:{s:121:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php\";}i:166;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":125:{s:116:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/RemoveAbstractDefinitionsPass.php\";}i:167;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":107:{s:99:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/RepeatedPass.php\";}i:168;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":140:{s:131:\"/vagrant/vendor/symfony/symfony/src/Symfony/Component/Dep"..., 8192) = 8192
read(25, "y/src/Symfony/Bundle/SecurityBundle/Resources/config/security_rememberme.xml\";}i:217;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":110:{s:101:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml\";}i:218;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":111:{s:102:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_twig.xml\";}i:219;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":105:{s:97:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/collectors.xml\";}i:220;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":100:{s:92:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/guard.xml\";}i:221;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":110:{s:101:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Resources/config/security_debug.xml\";}i:222;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":107:{s:99:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php\";}i:225;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":107:{s:99:\"/vagrant/ve"..., 8192) = 8192
read(25, "grant/vendor/symfony/swiftmailer-bundle/DependencyInjection/Configuration.php\";}i:275;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":83:{s:75:\"/vagrant/vendor/symfony/swiftmailer-bundle/Resources/config/swiftmailer.xml\";}i:276;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":90:{s:82:\"/vagrant/vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php\";}i:277;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":118:{s:109:\"/vagrant/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php\";}i:280;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":86:{s:78:\"/vagrant/vendor/doctrine/doctrine-bundle/DependencyInjection/Configuration.php\";}i:281;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":84:{s:76:\"/vagrant/vendor/doctrine/doctrine-cache-bundle/Resources/config/services.xml\";}i:282;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":74:{s:66:\"/vagrant/vendor/doctrine/doctrine-bundle/Resources/config/dbal.xml\";}i:283;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":73:{s:65:\"/vagrant/vendor/doctrine/doctrine-bundle/Resources/config/orm.xml\";}i:284;C:46:\"Symfony\\Component\\Config\\Resource\\FileResour"..., 8192) = 8192
read(25, "alidator.xml\";}i:341;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":82:{s:74:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/security.xml\";}i:342;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":78:{s:70:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/util.xml\";}i:343;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":80:{s:72:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/mailer.xml\";}i:344;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":83:{s:75:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/listeners.xml\";}i:345;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":93:{s:85:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/flash_notifications.xml\";}i:346;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":92:{s:84:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/username_form_type.xml\";}i:347;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":81:{s:73:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/profile.xml\";}i:348;C:46:\"Symfony\\Component\\Config\\Resource\\FileResource\":86:{s:78:\"/vagrant/vendor/friendsofsymfony/user-bundle/Resources/config/registrat"..., 8192) = 5259
read(25, "", 8192)                      = 0
read(25, "", 8192)                      = 0
close(25)                               = 0
poll([{fd=24, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
sendto(24, "*2\r\n$3\r\nGET\r\n$41\r\nphpspreadsheet.5bc41211f37c89.76849835.A1\r\n", 61, MSG_DONTWAIT, NULL, 0) = 61 poll([{fd=24, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=24, revents=POLLIN}])
recvfrom(24, "$", 1, MSG_PEEK, NULL, NULL) = 1
poll([{fd=24, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=24, revents=POLLIN}])
recvfrom(24, "$430\r\na:4:{i:0;b:1;i:1;O:34:\"PhpOffice\\PhpSpreadsheet\\Cell\\Cell\":6:{s:41:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0value\";s:3:\"sku\";s:51:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0calculatedValue\";N;s:44:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0dataType\";s:1:\"s\";s:42:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0parent\";N;s:43:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0xfIndex\";i:0;s:53:\"\0PhpOffice\\PhpSpreadsheet\\Cell\\Cell\0formulaAttributes\";N;}i:2;a:0:{}i:3;N;}\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 438
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
rt_sigaction(SIGSEGV, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7f6a6bcdc390}, NULL, 8) = 0
tgkill(19881, 19881, SIGSEGV)           = 0
rt_sigreturn({mask=[]})                 = 140094735159296
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_TKILL, si_pid=19881, si_uid=1000} ---
+++ killed by SIGSEGV +++
Segmentation fault

我不知道它是什么语言,但是从代码中可以清楚地看到与phpspreadsheet相关的代码正在运行。前几行是unserialize中的行。因此,很可能unserialize会触发phpspreadsheet中的某些方法。但是如何? unserialize的成功结果只是FileResource实例的数组。

0 个答案:

没有答案