nauxliu / opencc4php

简繁体转换 PHP 扩展
MIT License
458 stars 85 forks source link

当待翻译字符串包含某些特殊字符时,会导致返回502异常 #37

Closed xijiadmin closed 5 years ago

xijiadmin commented 6 years ago

https://github.com/NauxLiu/opencc4php/issues/24 ,为什么关了?是不是问题不予解决?需要其他的日志信息?或者别的?

pkujhd commented 6 years ago

没有足够的信息,如果你有类似的情况,并且php coredump,请上传一下core文件的函数调用栈. thx

xijiadmin commented 6 years ago

php版本:PHP 7.0.18 (cli) (built: Oct 24 2017 17:46:37) ( NTS ),安装了xdebug等插件 测试代码 :

<?php
$opencc = opencc_open('config' . DIRECTORY_SEPARATOR . 's2t.json');
opencc_convert(urldecode('%E8'), $opencc);
(gdb) bt
#0  0x00007f2dce7b594f in __strlen_sse42 () from /lib64/libc.so.6
#1  0x00007f2dc449dfaa in zif_opencc_convert (execute_data=<value optimized out>, return_value=0x7f2dcb2130d0)
    at /srv/source/php-ext-opencc4php/opencc.c:174
#2  0x00007f2dc513e045 in xdebug_execute_internal (current_execute_data=0x7f2dcb213230, return_value=0x7f2dcb2130d0)
    at /srv/source/xdebug-2.5.5/xdebug.c:2206
#3  0x0000000000853092 in ZEND_DO_FCALL_SPEC_HANDLER (execute_data=0x7f2dcb213030) at /srv/source/php-7.0.18/Zend/zend_vm_execute.h:844
#4  0x000000000082b960 in execute_ex (ex=<value optimized out>) at /srv/source/php-7.0.18/Zend/zend_vm_execute.h:417
#5  0x00007f2dc513e62f in xdebug_execute_ex (execute_data=0x7f2dcb213030) at /srv/source/xdebug-2.5.5/xdebug.c:2056
#6  0x000000000087f42b in zend_execute (op_array=0x7f2dcb27e000, return_value=<value optimized out>)
    at /srv/source/php-7.0.18/Zend/zend_vm_execute.h:458
#7  0x00000000007ebc43 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /srv/source/php-7.0.18/Zend/zend.c:1443
#8  0x000000000078dbd0 in php_execute_script (primary_file=0x7fff466aa470) at /srv/source/php-7.0.18/main/main.c:2492
#9  0x00000000008837aa in do_cli (argc=2, argv=0x1db0a30) at /srv/source/php-7.0.18/sapi/cli/php_cli.c:977
#10 0x0000000000883faa in main (argc=2, argv=0x1db0a30) at /srv/source/php-7.0.18/sapi/cli/php_cli.c:1347

注意:只有简体转换为繁体时,会出现这个问题

pkujhd commented 6 years ago

我build了php7.0.18, 并且使用了xdebug2.5.5 在centos6.3上未遇到相同的问题

[...@... tmp]$ php -v PHP 7.0.18 (cli) (built: Feb 9 2018 10:38:13) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans [...@... tmp]$ cat 1.php \<\?php $opencc = opencc_open('s2t.json'); $a = opencc_convert(urldecode('%E8'), $opencc); var_dump(bin2hex($a)); [...@... tmp]$ php 1.php /tmp/1.php:4: string(2) "e8"

如果可以的话,麻烦将core文件发送给我邮箱一下pkujhd@gmail.com

xijiadmin commented 6 years ago

已发送邮件,请查收

pkujhd commented 6 years ago

仍没有复现问题, 另外我看下一下奔溃栈 # 1 0x00007f2dc449dfaa in zif_opencc_convert (execute_data=, return_value=0x7f2dcb2130d0) at /srv/source/php-ext-opencc4php/opencc.c:174 这个地方的代码 168 #if PHP_MAJOR_VERSION < 7 169 char str = NULL; 170 int str_len; 171 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sr", &str, &str_len, &zod) == FAILURE) { 172 return; 173 } 174 od = (opencc_t)zod->value.lval; 175 176 outstr = opencc_convert_utf8(od, str, -1); 177 178 int len = strlen(outstr); 179 180 char rs = emalloc(sizeof(char) * (len + 1)); 181 strncpy(rs, outstr, len + 1); 182 opencc_convert_utf8_free(outstr); 183 184 RETURN_STRINGL(rs, len, 0); 185 #else 只有在php5的时候才会被调用.

是否你的什么配置存在问题