Skip to content
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

PHP7: php-mustache do not pass "make test" (segfaults) #21

Closed
macbre opened this issue Mar 2, 2016 · 12 comments
Closed

PHP7: php-mustache do not pass "make test" (segfaults) #21

macbre opened this issue Mar 2, 2016 · 12 comments

Comments

@macbre
Copy link

macbre commented Mar 2, 2016

I'm trying to compile php-mustache using PHP 7.0 and can't manage to make make test pass without causing segfaults.

Example test run:

macbre@dev-php7:~/php7/modules/php-mustache$ php -n -dextension=/home/macbre/php7/modules/php-mustache/modules/mustache.so tests/MustacheData____construct.phpt
--TEST--
MustacheData::__construct() member function
--SKIPIF--
--FILE--
string(12) "MustacheData"
--EXPECT--
string(12) "MustacheData"Segmentation fault (core dumped)

Backtrace from gdb:

Core was generated by `php -n -dextension=/home/macbre/php7/modules/php-mustache/modules/mustache.so t'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fabb31ded57 in mustache::Data::~Data() () from /usr/lib/x86_64-linux-gnu/libmustache.so.4
(gdb) bt
#0  0x00007fabb31ded57 in mustache::Data::~Data() () from /usr/lib/x86_64-linux-gnu/libmustache.so.4
#1  0x00007fabb33fe52a in MustacheData_obj_free (object=0x7fabb3a552d8) at /home/macbre/php7/modules/php-mustache/mustache_data.cpp:68
#2  0x0000000000753371 in zend_objects_store_del ()
#3  0x000000000072c9b5 in zend_hash_reverse_apply ()
#4  0x000000000070c70d in shutdown_destructors ()
#5  0x000000000071b404 in zend_call_destructors ()
#6  0x00000000006be425 in php_request_shutdown ()
#7  0x00000000007a0be2 in ?? ()
#8  0x00000000004712a0 in main ()

I assume that php-mustache is ready to be used in PHP7.

@jbboehr
Copy link
Owner

jbboehr commented Mar 3, 2016

@macbre Can you give me more information about your environment (php --version, distro, libmustache version, etc)? The Travis builds run on Precise, and I've run the tests on Trusty.

Yes, it's supposed to work in PHP7. Although, depending on your use case, the MustacheData class is probably not necessary.

@macbre
Copy link
Author

macbre commented Mar 7, 2016

PHP:

PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012

PHP 7.0.2-4+deb.sury.org~trusty+1 (cli) ( NTS )

libmustache: 0.4.0

Distro:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:    14.04
Codename:   trusty

@jbboehr
Copy link
Owner

jbboehr commented Mar 7, 2016

Strange, pretty close to my environment: 7.0.3-5+deb.sury.org~trusty+1

Can you post your gcc version and check if libmustache and php-mustache were both compiled with -std=gnu++11 or not?

I assume you're using either master or 0.7 of the extension?

@macbre
Copy link
Author

macbre commented Mar 8, 2016

@jbboehr,

  • php-miustache is compiled with -std=gnu++11 (using source code from master branch)
  • libmustache used is at v0.4.0 (compiled with -std=gnu++11 as well)
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 

@jbboehr
Copy link
Owner

jbboehr commented Mar 9, 2016

Maybe, can you send me this part of readelf -d modules/mustache.so

 0x0000000000000001 (NEEDED)             Shared library: [libmustache.so.4]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [mustache.so]
 0x000000000000000f (RPATH)              Library rpath: [/usr/local/lib]

Do any of the other tests fail? I can't seem to replicate. Your packages seem a bit older than mine, but I'm skeptical that's the issue.

Maybe try recompiling with -O0 so we can get a line number.

@macbre
Copy link
Author

macbre commented Mar 9, 2016

  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libmustache.so.4]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [mustache.so]

156 tests out of 187 are failing when using make test

@jbboehr
Copy link
Owner

jbboehr commented Mar 9, 2016

I re-ran Travis on Trusty: https://travis-ci.org/jbboehr/php-mustache/jobs/114873764 https://travis-ci.org/jbboehr/libmustache/builds/114874158

Can you think of anything about your environment that might be different? I don't really have any ideas at this point, and can't replicate. You might try updating your packages.

@jbboehr
Copy link
Owner

jbboehr commented Mar 9, 2016

You might try recompiling libmustache with ./configure CFLAGS='-g -O0' CXXFLAGS='-g -O0'

@macbre
Copy link
Author

macbre commented Mar 10, 2016

@jbboehr, many thanks for your help and hints! I'll try to recompile libmustache and get back with the results.

@macbre
Copy link
Author

macbre commented Mar 10, 2016

@jbboehr, success :) Recompiling libmustache did the trick!

=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :    0
Exts tested     :   40
---------------------------------------------------------------------

Number of tests :  187               182
Tests skipped   :    5 (  2.7%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    0 (  0.0%) (  0.0%)
Expected fail   :    0 (  0.0%) (  0.0%)
Tests passed    :  182 ( 97.3%) (100.0%)
---------------------------------------------------------------------
Time taken      :    4 seconds
=====================================================================

@macbre macbre closed this as completed Mar 10, 2016
@jbboehr
Copy link
Owner

jbboehr commented Mar 11, 2016

Did it work after recompiling without the CFLAGS?

@macbre
Copy link
Author

macbre commented Mar 11, 2016

Yes, it did

I was previously relying on our home made deb package with libmustache. After recompiling the lib from source it works like a charm. Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants