Code Monkey home page Code Monkey logo

Comments (18)

jmikola avatar jmikola commented on August 14, 2024

Cross-referencing with @alcaeus' report: https://gist.github.com/alcaeus/754e1458352e5e872f3c

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

I managed to reproduce this in the php-cli as well:

$ php -a
Interactive shell

php > $manager = new MongoDB\Driver\Manager('mongodb://localhost');
php > var_dump($manager);
Segmentation fault: 11

In this case, var_dumping the manager will cause the segfault. However, when adding arguments to the call it just segfaults right away:

$ php -a
Interactive shell

php > $manager = new \MongoDB\Driver\Manager("mongodb://localhost:27017", [], []);
Segmentation fault: 11

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

I just upgraded to 1.1.1 and was able to partly fix the issue.
The error still occurs when creating the manager with empty arrays for arguments (2nd example). The segmentation fault from the first example however is gone.

from mongo-php-driver.

jeremyjannotta avatar jeremyjannotta commented on August 14, 2024

I can confirm as well @alcaeus 's result, that after upgrading to v1.1.1, still segfaults with empty arrays.

from mongo-php-driver.

jmikola avatar jmikola commented on August 14, 2024

@jeremyjannotta: Were you able to create a GDB backtrace of your segfault? @alcaeus is in the process of creating his own, but it would certainly be helpful to have both to compare/contrast.

from mongo-php-driver.

jmikola avatar jmikola commented on August 14, 2024

Cross-referencing with PHPC-493.

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

Here goes:

$ gdb php
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin15.2.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from php...(no debugging symbols found)...done.
(gdb) run -r "new MongoDB\Driver\Manager('mongodb://localhost', [], []);"
Starting program: /usr/local/bin/php -r "new MongoDB\Driver\Manager('mongodb://localhost', [], []);"

Program received signal SIGSEGV, Segmentation fault.
0x00000001003cbb09 in zend_hash_num_elements ()
(gdb) bt full
#0  0x00000001003cbb09 in zend_hash_num_elements ()
No symbol table info available.
#1  0x0000000104c2de96 in zval_to_bson () from /usr/local/opt/php56-mongo/mongo.so
No symbol table info available.
#2  0x0000000104c855e3 in zim_Manager___construct () from /usr/local/opt/php56-mongodb/mongodb.so
No symbol table info available.
#3  0x00000001003b0ca9 in dtrace_execute_internal ()
No symbol table info available.
#4  0x00000001017c2776 in xdebug_execute_internal () from /usr/local/opt/php56-xdebug/xdebug.so
No symbol table info available.
#5  0x0000000100429fce in zend_do_fcall_common_helper_SPEC ()
No symbol table info available.
#6  0x00000001003e718e in execute_ex ()
No symbol table info available.
#7  0x00000001003b0be5 in dtrace_execute_ex ()
No symbol table info available.
#8  0x00000001017c245c in xdebug_execute_ex () from /usr/local/opt/php56-xdebug/xdebug.so
No symbol table info available.
#9  0x00000001003b2f4b in zend_eval_stringl ()
No symbol table info available.
#10 0x00000001003b328a in zend_eval_stringl_ex ()
No symbol table info available.
#11 0x000000010044aa82 in do_cli ()
No symbol table info available.
#12 0x0000000100449c8b in main ()
No symbol table info available.

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

@jeremyjannotta Do you, by any chance, also have ext-mongo installed next to ext-mongodb? Working on that adapter between these two I removed ext-mongo for testing purposes and all of a sudden the code used above no longer segfaulted.

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

As I can't repro this, could you run it again in debug mode? -- It'll print out a little more info for debugging:

So in gdb run:

(gdb) run -dmongodb.debug=stderr -r "new MongoDB\Driver\Manager('mongodb://localhost', [], []);"

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

@bjori Same result - there is no additional output and the trace is exactly the same.

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

Heh. I see now why there is no additional output. It segfaults as soon as it tries to convert the options... Doesn't make any sense :|

Which PHP version is this? And you are running pecl/mongodb 1.1.1?

Could you just for completeness try without xdebug?

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

As commented above, I have updated to 1.1.1 which solved one segfault I was experiencing.

I've previously tried running without xdebug after @jmikola suspected that and it didn't change a thing. Here's the output without xdebug:

(gdb) bt full
#0  0x00000001003cbb09 in zend_hash_num_elements ()
No symbol table info available.
#1  0x0000000104bf7e96 in zval_to_bson () from /usr/local/opt/php56-mongo/mongo.so
No symbol table info available.
#2  0x0000000104c4f5e3 in zim_Manager___construct () from /usr/local/opt/php56-mongodb/mongodb.so
No symbol table info available.
#3  0x00000001003b0ca9 in dtrace_execute_internal ()
No symbol table info available.
#4  0x0000000100429fce in zend_do_fcall_common_helper_SPEC ()
No symbol table info available.
#5  0x00000001003e718e in execute_ex ()
No symbol table info available.
#6  0x00000001003b0be5 in dtrace_execute_ex ()
No symbol table info available.
#7  0x00000001003b2f4b in zend_eval_stringl ()
No symbol table info available.
#8  0x00000001003b328a in zend_eval_stringl_ex ()
No symbol table info available.
#9  0x000000010044aa82 in do_cli ()
No symbol table info available.
#10 0x0000000100449c8b in main ()
No symbol table info available.

Again, disabling pecl/mongo fixes the issue.

Also:

$ php --version
PHP 5.6.16 (cli) (built: Nov 27 2015 10:28:34) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

from mongo-php-driver.

bjori avatar bjori commented on August 14, 2024

Bahhh. Sorry for being so daft. It even worked for me locally on PHP 5.6.16 with both pecl/mongo and pecl/mongodb loaded -- but now I see what the problem is, I wasn't reading the paths from your stack trace correctly.

There is a symbol clash between pecl/mongodb and pecl/mongo, more specifically zval_to_bson is provided by both extensions.

In your case, the stacktrace shows the zim_Manager___construct() executing the zval_to_bson() function provided by mongo.so -- not mongodb.so.
These two functions don't share any implementation details and are not compatible with each other.

We'll have to rename the function provided by pecl/mongodb to phongo_zval_to_bson or something.

from mongo-php-driver.

alcaeus avatar alcaeus commented on August 14, 2024

Now that you mention it, yes, it does say mongo.so. I didn't catch that either. Well, at least we now know what the problem is! 👍

from mongo-php-driver.

jeremyjannotta avatar jeremyjannotta commented on August 14, 2024

@alcaeus I do indeed have ext-mongo installed next to ext-mongodb.

Also, here is my gdb backtrace, which has the same result:

Program received signal SIGSEGV, Segmentation fault.
0x0000000100473db4 in zend_hash_num_elements ()
(gdb) bt full
#0  0x0000000100473db4 in zend_hash_num_elements ()
No symbol table info available.
#1  0x0000000104c6f85a in zval_to_bson () from /usr/local/php5/lib/php/extensions/no-debug-non-zts-20131226/mongo.so
No symbol table info available.
#2  0x0000000104cd44cf in zim_Manager___construct ()
   from /usr/local/php5/lib/php/extensions/no-debug-non-zts-20131226/mongodb.so
No symbol table info available.
#3  0x00000001004565de in dtrace_execute_internal ()
No symbol table info available.
#4  0x0000000101d9232f in xdebug_execute_internal ()
   from /usr/local/php5/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
No symbol table info available.
#5  0x00000001004d6c58 in zend_do_fcall_common_helper_SPEC ()
No symbol table info available.
#6  0x0000000100491918 in execute_ex ()
No symbol table info available.
#7  0x0000000100456512 in dtrace_execute_ex ()
No symbol table info available.
#8  0x0000000101d92060 in xdebug_execute_ex ()
   from /usr/local/php5/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
No symbol table info available.
#9  0x0000000100458cf4 in zend_eval_stringl ()
No symbol table info available.
#10 0x000000010045910c in zend_eval_string_ex ()
No symbol table info available.
#11 0x00000001004f80ed in do_cli ()
No symbol table info available.
#12 0x00000001004f72b8 in main ()
No symbol table info available.

from mongo-php-driver.

jeremyjannotta avatar jeremyjannotta commented on August 14, 2024

Confirmed as well that disabling ext-mongo fixes the segfault issue.

from mongo-php-driver.

jmikola avatar jmikola commented on August 14, 2024

Cross-referencing with PHPC-529. Thanks for following up with the traces, guys!

from mongo-php-driver.

jmikola avatar jmikola commented on August 14, 2024

1.1.2 has been released with a fix for this.

from mongo-php-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.