zephir
zephir copied to clipboard
seg fault when i do several calls to zephir functions
Hi
Im getting seg fault core dump when i run several
The issue persists across various PHP versions and the latest Zephir version. Compiling with debug isn't an option because the ionCube loader doesn't support it, and other script functions rely on ionCube. The problem seems to be related to memory overwrites, as indicated by the issue being resolved when using USE_ZEND_ALLOC=0. Interestingly, reducing the code size or commenting out any single functions prevents the segmentation fault from occurring.
zend_mm_alloc_small (bin_num=5, heap=0x7ffff4400040) at /home/xui/bin/php-7.4.10/Zend/zend_alloc.c:1255
1255 heap->free_slot[bin_num] = p->next_free_slot;
1: x/i $pc
=> 0x555555a74ea8 <_emalloc+104>: mov (%rax),%rcx
(gdb) list
1250 } while (0);
1251 #endif
1252
1253 if (EXPECTED(heap->free_slot[bin_num] != NULL)) {
1254 zend_mm_free_slot p = heap->free_slot[bin_num];
1255 heap->free_slot[bin_num] = p->next_free_slot;
1256 return (void)p;
1257 } else {
1258 return zend_mm_alloc_small_slow(heap, bin_num ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1259 }
(gdb) bt
#0 zend_mm_alloc_small (bin_num=5, heap=0x7ffff4400040) at /home/xui/bin/php-7.4.10/Zend/zend_alloc.c:1255
#1 zend_mm_alloc_heap (size=
heres another
gdb --args /home/xui/bin/php/bin/php ../../www/getxui.php
(gdb) display/i $pc
(gdb) run
Starting program: /home/xui/bin/php/bin/php ../../www/getxui.php
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffd33bb700 (LWP 1633712)]
[Thread 0x7fffd33bb700 (LWP 1633712) exited]
Thread 1 "php" received signal SIGSEGV, Segmentation fault.
zend_mm_alloc_small (bin_num=5, heap=0x7ffff4400040) at /home/xui/bin/php-7.4.10/Zend/zend_alloc.c:1255
1255 heap->free_slot[bin_num] = p->next_free_slot;
1: x/i $pc
=> 0x555555a636a8 <_emalloc+104>: mov (%rax),%rcx
(gdb) bt
#0 zend_mm_alloc_small (bin_num=5, heap=0x7ffff4400040) at /home/xui/bin/php-7.4.10/Zend/zend_alloc.c:1255
#1 zend_mm_alloc_heap (size=
Segmentation fault (core dumped)
Could you provide code example where it occurs?
hi i have put the code here https://github.com/vital121/test/tree/main seems to happen at various places if i comment out one line that seems to cause it then it seems to move to another line in a differnet function for instance if you uncomment line 805 from functions.zep //print_r("self::license" . self::license); it doesnt core dump when line 806 print_r(self::license); runs
Hello. Yes, I too have been facing this problem for two years now. The problem has been in many different versions of Zephir. Including the latest one. Issue opener has already provided a code.
My case is the same:
- I use some compiled functions of a Zephir extension in PHP code
- I then continue to execute the normal PHP code (no longer calling Zephir), and a "Segmentation fault" error is displayed.
- I completely remove (or comment) the piece of PHP code where this error appears, and replace it with different code. The same error begins to occur on a different piece of code. This is happening specifically after using Zephir
Two years ago I temporarily solved the problem by running Zephir function calls in a separate PHP script, running another PHP instance by shell_exec and passing call parameters and return value via base64encode(serialize($value)) 🙄🙄
But now I am facing this problem again. @Jeckerson, thank you in advance 🙏
code is here https://github.com/vital121/test/tree/main
@Jeckerson did you see code?