Opened 5 years ago

Closed 5 years ago

#748 closed defect (fixed)

PHP7 bindings segfaults

Reported by: Victor Sakovich Owned by: Olly Betts
Priority: normal Milestone: 1.4.4
Component: Xapian-bindings (PHP) Version: 1.4.3
Severity: normal Keywords: PHP7
Cc: Blocked By:
Blocking: Operating System: Linux


I have issue while running Xapian with CentOS7 x86_64. My environment is:

~ cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
~ rpm  -qa | grep php
~ php -i | grep -A 3 Xapian
Xapian Support => enabled
Xapian Compiled Version => 1.4.3
Xapian Linked Version => 1.4.3

PHP packages are taken from , and Xapian packages are compiled from the source.

The issue is that PHP segfaults. For example "gdb php" run with "-i" option results in:

Program received signal SIGSEGV, Segmentation fault.
0x00005555557e1b09 in _zval_ptr_dtor ()
(gdb) backtrace 
#0  0x00005555557e1b09 in _zval_ptr_dtor ()
#1  0x00005555557e0082 in free_zend_constant ()
#2  0x00005555558038a2 in zend_hash_destroy ()
#3  0x00005555557f2039 in zend_shutdown ()
#4  0x000055555578fffb in php_module_shutdown ()
#5  0x00005555556252c5 in main ()

Here is additional information as reported by valgrind:

~ USE_ZEND_ALLOC=0 valgrind --tool=memcheck  php -v
==12785== Memcheck, a memory error detector
==12785== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==12785== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==12785== Command: php -v
PHP 7.1.2 (cli) (built: Feb 18 2017 11:22:37) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
==12785== HEAP SUMMARY:
==12785==     in use at exit: 8,107 bytes in 94 blocks
==12785==   total heap usage: 21,692 allocs, 21,598 frees, 2,271,702 bytes allocated
==12785== LEAK SUMMARY:
==12785==    definitely lost: 4,320 bytes in 28 blocks
==12785==    indirectly lost: 2,269 bytes in 36 blocks
==12785==      possibly lost: 0 bytes in 0 blocks
==12785==    still reachable: 1,518 bytes in 30 blocks
==12785==         suppressed: 0 bytes in 0 blocks
==12785== Rerun with --leak-check=full to see details of leaked memory
==12785== For counts of detected and suppressed errors, rerun with: -v
==12785== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Please let me know if you need to provide additional information.

Change History (6)

comment:1 by Victor Sakovich, 5 years ago

I have tried to build the latest Xapian source from, however has the same issue.

comment:2 by Olly Betts, 5 years ago

From the backtrace, I suspect this SWIG bug:

If so, you can probably work around this by manually changing 0 to CONST_PERSISTENT | CONST_CS in the definition of SWIG_Php_SetModule in php7/php7/ before compiling.

comment:3 by Victor Sakovich, 5 years ago

This fixed the issue. Thank you. The fix is:

@@ -974,7 +974,7 @@
 static void SWIG_Php_SetModule(swig_module_info *pointer) {
-  REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0);
 /*  Errors in SWIG */
Last edited 5 years ago by Victor Sakovich (previous) (diff)

comment:4 by Olly Betts, 5 years ago

Milestone: 1.4.x1.4.4
Owner: set to Olly Betts
Status: newassigned

Fixed in git master by [e196773173d344f108821f68521c15c048eca3fe/git]. Marking for backport for next 1.4 release.

comment:5 by Olly Betts, 5 years ago

And thanks for confirming the fix!

comment:6 by Olly Betts, 5 years ago

Resolution: fixed
Status: assignedclosed

Backported to RELEASE/1.4 in f69805d622aba0c0cf61fd74a362540180388319.

Note: See TracTickets for help on using tickets.