GithubHelp home page GithubHelp logo

Comments (11)

acim avatar acim commented on July 19, 2024

This is maybe not related to MongoDB, but to container that I use for DI (PHP League). If I try the same thing from simple script, it works. However, if I inject Collection object via container, it crashes. I will investigate further.

from mongo-php-library.

jmikola avatar jmikola commented on July 19, 2024

Do you also have the legacy driver (i.e. mongo.so) loaded? This may be related to mongodb/mongo-php-driver#173 and mongodb/mongo-php-driver#194 (PR for PHPC-529).

from mongo-php-library.

acim avatar acim commented on July 19, 2024

No, mongo.so is not present on the system. I tried this with PHP 7.0.1 also and the same problem is present there.

What I have found out, if I execute any method on Collection object within containers closure, this works no problem :) This is the original code (League Container service provider):

        $this->getContainer()->add('mongo-collection', function () {
            $context = stream_context_create(['ssl' => [
                'allow_self_signed' => true,
                'verify_peer'       => false,
                'verify_peer_name'  => false,
                'verify_expiry'     => false]
            ]);

            $manager = new Manager('mongodb://127.0.0.1:27017', ['ssl' => true], ['context' => $context]);

            $collection = new Collection($manager, 'dbName.collectionName');

            return $collection;
        });

And if I add:

$collection->count();

right before the return, it works. If I comment it out, I get segfault. I have also tried other methods like findOne() and it again works.

from mongo-php-library.

acim avatar acim commented on July 19, 2024

Here is the gdb output:

Program received signal SIGSEGV, Segmentation fault.
0x000000010036bf5f in php_stream_context_set ()

from mongo-php-library.

jmikola avatar jmikola commented on July 19, 2024

@acim: Any chance you can get a more thorough backtrace (these docs may help)? That output looks like it may just be the top stack frame.

from mongo-php-library.

acim avatar acim commented on July 19, 2024
boban:htdocs acim$ gdb /usr/local/bin/php /cores/core.6644 
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 /usr/local/bin/php...(no debugging symbols found)...done.
"/cores/core.6644": no core file handler recognizes format
(gdb) bt
No stack.

from mongo-php-library.

acim avatar acim commented on July 19, 2024

So, OSX core files seem to be non-supported by gdb. I have tried today to compile pecl version of mongodb and it crashes the same way. So this is not a homebrew issue, there is something wrong with mongodb.

from mongo-php-library.

acim avatar acim commented on July 19, 2024

Segmentation fault occurs on Linux also :(

Program received signal SIGSEGV, Segmentation fault.
0x000000000078c9bf in zend_hash_find ()
(gdb) bt
#0  0x000000000078c9bf in zend_hash_find ()
#1  0x00000000007391a4 in php_stream_context_get_option ()
#2  0x00000000004bf7d7 in php_openssl_ssl_socket_factory ()
#3  0x000000000074225e in _php_stream_xport_create ()
#4  0x00007fffee80ff4d in phongo_stream_initiator ()
   from /usr/lib64/php5.4/lib/extensions/no-debug-non-zts-20100525/mongodb.so
#5  0x00007fffee800dde in mongoc_topology_scanner_node_setup ()
   from /usr/lib64/php5.4/lib/extensions/no-debug-non-zts-20100525/mongodb.so
#6  0x00007fffee801364 in mongoc_topology_scanner_start ()
   from /usr/lib64/php5.4/lib/extensions/no-debug-non-zts-20100525/mongodb.so
#7  0x00007fffee80015e in mongoc_topology_select ()
   from /usr/lib64/php5.4/lib/extensions/no-debug-non-zts-20100525/mongodb.so
#8  0x00007fffee7bc657 in zim_Manager_selectServer ()
   from /usr/lib64/php5.4/lib/extensions/no-debug-non-zts-20100525/mongodb.so
#9  0x00000000008288bc in ?? ()
#10 0x00000000007a5b07 in execute ()
#11 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#12 0x0000000000828dd6 in ?? ()
#13 0x00000000007a5b07 in execute ()
#14 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#15 0x0000000000828dd6 in ?? ()
#16 0x00000000007a5b07 in execute ()
#17 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#18 0x0000000000828dd6 in ?? ()
#19 0x00000000007a5b07 in execute ()
#20 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#21 0x0000000000828dd6 in ?? ()
#22 0x00000000007a5b07 in execute ()
#23 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#24 0x0000000000828dd6 in ?? ()
#25 0x00000000007a5b07 in execute ()
---Type <return> to continue, or q <return> to quit---
#26 0x00007fffee326820 in nr_php_execute ()
    at /home/hudson/slave-workspace/workspace/PHP_Release_Agent/label/centos5-64-nrcamp/agent/php_execute.c:1158
#27 0x000000000077fe54 in zend_execute_scripts ()
#28 0x0000000000720ed7 in php_execute_script ()
#29 0x000000000082a8cc in ?? ()
#30 0x000000000047d9e6 in main ()

from mongo-php-library.

jmikola avatar jmikola commented on July 19, 2024

Sorry for the delayed response. We'll track this in PHPC-572. Since you mentioned that $collection->count(); seemed to avoid the segfault, I believe this is due to the stream context going out of scope before we get a chance to initialize the Manager's sockets.

from mongo-php-library.

igorwwwwwwwwwwwwwwwwwwww avatar igorwwwwwwwwwwwwwwwwwwww commented on July 19, 2024

We ran into this problem as well. The workaround we came up with was to store the stream context and the mongodb Manager (in this case a MongoClient from alcaeus/mongo-php-adapter) in static properties, preventing them from being garbage collected -- and ensuring that we only create one Manager instance ever.

from mongo-php-library.

jmikola avatar jmikola commented on July 19, 2024

This has been fixed in ext-mongodb 1.1.7.

/cc @bashofmann in case this is still affecting ResearchGate

from mongo-php-library.

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.