Closed aleksandardragojlovic closed 6 years ago
Extension has been removed right now. If I install php71-mongodb my PHP will crash again. If you need anything else please let me know.
We'd need a strack trace made with GDB, as is explained at https://bugs.php.net/bugs-generating-backtrace.php
@derickr I am not sure how to generate it in macOS
Exactly the same as on Linux :-) You might have to install GDB though.
@derickr I hope this is it:
➜ ~ sudo gdb /usr/local/bin/httpd
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-darwin17.0.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/httpd...(no debugging symbols found)...done.
(gdb) run -X
Starting program: /usr/local/bin/httpd -X
[New Thread 0x1303 of process 2051]
warning: unhandled dyld version (15)
Thread 2 received signal SIGSEGV, Segmentation fault.
0x00007fff74bfd3a4 in ?? ()
(gdb) bt
#0 0x00007fff74bfd3a4 in ?? ()
#1 0x00007fff74c1778f in ?? ()
#2 0x0000000105e000f0 in ?? ()
#3 0x0000000000000000 in ?? ()
(gdb) bt
#0 0x00007fff74bfd3a4 in ?? ()
#1 0x00007fff74c1778f in ?? ()
#2 0x0000000105e000f0 in ?? ()
#3 0x0000000000000000 in ?? ()
(gdb) quit
A debugging session is active.
Inferior 1 [process 2051] will be killed.
Quit anyway? (y or n) y
I've made issue #682 and andreas suggest that my issue is same with this one. But I install mongo-php-driver using pecl, not homebrew. After I follow instruction to debug with gdb, i have exactly same bug report with @aleksandardragojlovic . So, how to solve it? Thank.
@aleksandardragojlovic, @deboraglory, unfortunately this GDB trace is not useful, as it doesn't give any lines of code etc. This is because apparently your "httpd" has no debugging symbols.
It would be really useful if you could try this on the command line as well, with "gdb --args php", and see whether it happens there as well.
If I may act on a hunch, I think what is happening is that there are two different openssl libraries being used here. One in "httpd" and one for the PHP driver. In order to test this theory, can you also run:
otool -L /usr/local/bin/httpd
and
otool -L /full/path/to/mongodb.so
(replace the path in this one, with the one where your mongodb.so
file resides.
@derickr gdb --args php has the same result
Deboras-MacBook-Air:bin debora$ sudo gdb --args php
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-darwin17.0.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 -X
Starting program: /Applications/MAMP/bin/php/php5.6.30/bin/php -X
[New Thread 0x1303 of process 78617]
warning: unhandled dyld version (15)
httpd check
Deboras-MacBook-Air:bin debora$ otool -L /usr/local/bin/httpd
/usr/local/bin/httpd:
/usr/local/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.9.0)
/usr/local/opt/apr-util/libexec/lib/libaprutil-1.0.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 8.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/opt/apr/libexec/lib/libapr-1.0.dylib (compatibility version 7.0.0, current version 7.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
Deboras-MacBook-Air:bin debora$ otool -L /Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/mongodb.so
/Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/mongodb.so:
/usr/lib/libsasl2.2.dylib (compatibility version 3.0.0, current version 3.15.0)
/usr/lib/libssl.35.dylib (compatibility version 36.0.0, current version 36.0.0)
/usr/lib/libcrypto.35.dylib (compatibility version 36.0.0, current version 36.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
BTW, when i start MAMP the one httpd run is from /Applications/MAMP/Library/bin/httpd.
Deboras-MacBook-Air:bin debora$ otool -L /Applications/MAMP/Library/bin/httpd
/Applications/MAMP/Library/bin/httpd:
/usr/lib/libaprutil-1.0.dylib (compatibility version 4.0.0, current version 4.12.0)
/Applications/MAMP/Library/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 7.2.0)
/Applications/MAMP/Library/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
/usr/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 158.0.0)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
/usr/lib/libapr-1.0.dylib (compatibility version 5.0.0, current version 5.5.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
@aleksandardragojlovic: Can you follow up with otool -L
output for your httpd
, php
, and mongodb.so
binaries?
Based on discussion in #682, I think we've concluded that @deboraglory's issue is due to conflicting versions of OpenSSL. Her web server runtime is using OSX's system library (boringssl), but the version of PHP and mongodb.so
installed with Homebrew are using the proper version of OpenSSL (installed via Homebrew). This was confirmed by examining otool -L
output for the php
and mongodb.so
binaries installed via Homebrew. While httpd
did not report libboringssl.dylib
in its otool -L
output, we can infer it is being used at runtime thanks to the crash report she provided.
Please see my response in https://github.com/mongodb/mongo-php-driver/issues/682#issuecomment-349345356 and let me know if that can be applied in your situation.
Hello,
➜ ~ which php
/usr/local/bin/php
➜ ~ otool -L /usr/local/bin/php
/usr/local/bin/php:
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.15.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/readline/lib/libreadline.7.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
/usr/local/opt/libpng/lib/libpng16.16.dylib (compatibility version 51.0.0, current version 51.0.0)
/usr/local/opt/jpeg/lib/libjpeg.9.dylib (compatibility version 12.0.0, current version 12.0.0)
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
/usr/local/opt/libxml2/lib/libxml2.2.dylib (compatibility version 12.0.0, current version 12.7.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
/usr/local/opt/freetype/lib/libfreetype.6.dylib (compatibility version 22.0.0, current version 22.0.0)
/usr/local/opt/unixodbc/lib/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 59.1.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
➜ ~ which httpd
/usr/local/bin/httpd
➜ ~ otool -L /usr/local/bin/httpd
/usr/local/bin/httpd:
/usr/local/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.9.0)
/usr/local/opt/apr-util/libexec/lib/libaprutil-1.0.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 8.0.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/local/opt/apr/libexec/lib/libapr-1.0.dylib (compatibility version 7.0.0, current version 7.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
➜ ~ otool -l /usr/local/opt/php71-mongodb/mongodb.so
/usr/local/opt/php71-mongodb/mongodb.so:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
0xfeedfacf 16777223 3 0x00 8 16 1800 0x00018004
Load command 0
cmd LC_SEGMENT_64
cmdsize 552
segname __TEXT
vmaddr 0x0000000000000000
vmsize 0x0000000000088000
fileoff 0
filesize 557056
maxprot 0x00000007
initprot 0x00000005
nsects 6
flags 0x0
Section
sectname __text
segname __TEXT
addr 0x00000000000021e0
size 0x000000000006c978
offset 8672
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __stubs
segname __TEXT
addr 0x000000000006eb58
size 0x00000000000019b0
offset 453464
align 2^1 (2)
reloff 0
nreloc 0
flags 0x80000408
reserved1 0 (index into indirect symbol table)
reserved2 6 (size of stubs)
Section
sectname __stub_helper
segname __TEXT
addr 0x0000000000070508
size 0x0000000000002ad8
offset 460040
align 2^2 (4)
reloff 0
nreloc 0
flags 0x80000400
reserved1 0
reserved2 0
Section
sectname __const
segname __TEXT
addr 0x0000000000072fe0
size 0x0000000000001b38
offset 471008
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __cstring
segname __TEXT
addr 0x0000000000074b20
size 0x0000000000012344
offset 477984
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000002
reserved1 0
reserved2 0
Section
sectname __unwind_info
segname __TEXT
addr 0x0000000000086e64
size 0x0000000000001198
offset 552548
align 2^2 (4)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Load command 1
cmd LC_SEGMENT_64
cmdsize 632
segname __DATA
vmaddr 0x0000000000088000
vmsize 0x0000000000010000
fileoff 557056
filesize 32768
maxprot 0x00000007
initprot 0x00000003
nsects 7
flags 0x0
Section
sectname __nl_symbol_ptr
segname __DATA
addr 0x0000000000088000
size 0x0000000000000010
offset 557056
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000006
reserved1 1096 (index into indirect symbol table)
reserved2 0
Section
sectname __got
segname __DATA
addr 0x0000000000088010
size 0x0000000000000378
offset 557072
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000006
reserved1 1098 (index into indirect symbol table)
reserved2 0
Section
sectname __la_symbol_ptr
segname __DATA
addr 0x0000000000088388
size 0x0000000000002240
offset 557960
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000007
reserved1 1209 (index into indirect symbol table)
reserved2 0
Section
sectname __const
segname __DATA
addr 0x000000000008a5d0
size 0x0000000000003650
offset 566736
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __data
segname __DATA
addr 0x000000000008dc20
size 0x0000000000002320
offset 580640
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000000
reserved1 0
reserved2 0
Section
sectname __bss
segname __DATA
addr 0x000000000008ff40
size 0x0000000000007af0
offset 0
align 2^4 (16)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0
Section
sectname __common
segname __DATA
addr 0x0000000000097a30
size 0x0000000000000440
offset 0
align 2^3 (8)
reloff 0
nreloc 0
flags 0x00000001
reserved1 0
reserved2 0
Load command 2
cmd LC_SEGMENT_64
cmdsize 72
segname __LINKEDIT
vmaddr 0x0000000000098000
vmsize 0x000000000002d000
fileoff 589824
filesize 183332
maxprot 0x00000007
initprot 0x00000001
nsects 0
flags 0x0
Load command 3
cmd LC_DYLD_INFO_ONLY
cmdsize 48
rebase_off 589824
rebase_size 608
bind_off 590432
bind_size 5968
weak_bind_off 596400
weak_bind_size 56
lazy_bind_off 596456
lazy_bind_size 35680
export_off 632136
export_size 26792
Load command 4
cmd LC_SYMTAB
cmdsize 24
symoff 661784
nsyms 2340
stroff 708444
strsize 64712
Load command 5
cmd LC_DYSYMTAB
cmdsize 80
ilocalsym 0
nlocalsym 788
iextdefsym 788
nextdefsym 1240
iundefsym 2028
nundefsym 312
tocoff 0
ntoc 0
modtaboff 0
nmodtab 0
extrefsymoff 0
nextrefsyms 0
indirectsymoff 699224
nindirectsyms 2305
extreloff 0
nextrel 0
locreloff 0
nlocrel 0
Load command 6
cmd LC_UUID
cmdsize 24
uuid FA6B6BCF-D0D9-36BD-AF92-62469952C0DC
Load command 7
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.13
sdk 10.13
Load command 8
cmd LC_SOURCE_VERSION
cmdsize 16
version 0.0
Load command 9
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libsasl2.2.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 3.15.0
compatibility version 3.0.0
Load command 10
cmd LC_LOAD_DYLIB
cmdsize 72
name /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 1.0.0
compatibility version 1.0.0
Load command 11
cmd LC_LOAD_DYLIB
cmdsize 80
name /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 1.0.0
compatibility version 1.0.0
Load command 12
cmd LC_LOAD_DYLIB
cmdsize 56
name /usr/lib/libSystem.B.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 1252.0.0
compatibility version 1.0.0
Load command 13
cmd LC_RPATH
cmdsize 40
path /usr/local/opt/openssl/lib (offset 12)
Load command 14
cmd LC_FUNCTION_STARTS
cmdsize 16
dataoff 658928
datasize 2560
Load command 15
cmd LC_DATA_IN_CODE
cmdsize 16
dataoff 661488
datasize 296
➜ ~
@jmikola I have pasted an output from my Terminal. Thank you.
@aleksandardragojlovic: You may want to edit your last comment. otool -l
is not the same as otool -L
(re: mongodb.so
report).
➜ ~ otool -L /usr/local/opt/php71-mongodb/mongodb.so
/usr/local/opt/php71-mongodb/mongodb.so:
/usr/lib/libsasl2.2.dylib (compatibility version 3.0.0, current version 3.15.0)
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
@jmikola I made a mistake. I have added new comment.
Based on your otool -L
output you provided and the fact that Apache, PHP, and the driver have all been installed via Homebrew, I believe you're facing the same issue as @adamwinn in #682. Please read https://github.com/mongodb/mongo-php-driver/issues/682#issuecomment-349409777 onward (note that I incorrectly assumed he was using the macOS version of httpd
in the first comment linked).
To reiterate here, the root cause of this is httpd
loading BoringSSL at runtime, despite PHP and its extensions being compiled against OpenSSL. I don't understand why a version of Apache installed through Homebrew would not utilize Homebrew's OpenSSL library, but that's something I've asked @adamwinn to follow up on (with the Apache formula maintainers).
In the driver itself, we're aiming to utilize Secure Transport instead of OpenSSL on macOS with PHPC-888 for 1.4.0, which would circumvent this issue. That said, the conflict between BoringSSL and OpenSSL is still an open issue (if not for our extension after 1.4.0, then certainly for any other PHP application using OpenSSL -- such as the OpenSSL API itself).
What is the solution for this issue now? Lot of our development environment are unusable due to this issue! @jmikola
What is the solution for this issue now?
@sibidharan: I believe the best workaround at present is to switch from mod_php
to PHP FPM, as you've documented in https://github.com/Homebrew/homebrew-core/issues/21475#issuecomment-350458394. Folks in the Homebrew project have observed crashes with at least one other extension (SNMP) and are aware of the issue with Apache loading BoringSSL. That said, this issue is not specific to Homebrew, as the OP in #682 reported a similar crash using MAMP.
I expect PHPC-888 is the best long term solution to this issue (at least for the MongoDB driver).
@jmikola I also observed that if I compile mongodb.so
from a macOS Sierra, it is not crashing. So that is a better alternate, if someone is able to compile it on macOS Sierra and use it in macOS High Sierra. This is a easiest and short one. But I need to test it more before documenting it. In that case, we can provide the extension file for everyone who is facing the issue. I am unaware how far it is going to work.
Let's see what the future holds!
Switching to php fpm works for me. Thank you very much.
In that case, we can provide the extension file for everyone who is facing the issue.
@sibidharan: We've no plans to start providing object files, although you're certainly free to do so on your own. PECL provides its own DLLs for Windows users, but that's a special case given the complexity of Windows' build environment.
But considering this crash is not unique to Homebrew (at least one user experienced it from a basic PECL install, which didn't involve Homebrew's OpenSSL), I'm doubtful that a pre-compiled mongodb.so
file is going to be more reliable than switching to PHP FPM. For instance, if you build mongodb.so
for OpenSSL 1.1 and someone attempts to use it with an earlier OpenSSL version, a crash might still occur.
@jmikola That is true. Then for now, let's stick with FPM until 1.4.0 driver for mongodb is out!
@aleksandardragojlovic httpd is not crashing anymore. I said what I did in in https://github.com/Homebrew/homebrew-core/issues/21475#issuecomment-350458394, which solved my issue 💯
libmongoc SSL library is Secure Transport now :D
Per my response in https://github.com/Homebrew/homebrew-php/issues/4607#issuecomment-359929194, this should be addressed by the recently tagged 1.4.0RC1 release. If you build from source, as the Homebrew formula does, you can provide --with-mongodb-ssl=darwin
to configure
and instruct the driver to utilize macOS Secure Transport instead of OpenSSL (and bypass the BoringSSL conflict).
@abinhho the information is heavily outdated.
For one, with ext-mongodb
1.4.0 and later, you can specify which SSL library you want to use using the --with-mongodb-ssl
configure switch. Starting with 1.4.3, the configure script automatically prefers Secure Transport on MacOS, so you can simply run pecl install mongodb
and it should work out of the box without manually calling configure
.
Furthermore, the instructions to install PHP are also outdated and will no longer work - the php71
brew package is long gone in favor of php@7.1
. In the future, please ensure instructions are still valid before copy-pasting them from one ticket to another. Thanks.
Description
I have created an issue: https://github.com/Homebrew/homebrew-php/issues/4607 . Andreas told me to create new issue here, since it doesn't seem to be a problem specific to homebrew.
After I install php71-mongodb my php stop working.
I have installed on clean system (High Sierra) php71 with necessary extensions. When I install mongoDB my php stop working. In system.log I see segmentation errors. When I uninstall mongoDB php ext. everything is working correctly.
Environment
macOS High Sierra 10.13.1 (17B1002)
PHP installed via homebrew. In formula, I believe it uses pecl to install mongodb.
PHP 7.1.11 (cli) (built: Nov 28 2017 11:35:47) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
php -i