Bug 233024

Summary: lang/php73: Bus error
Product: Ports & Packages Reporter: Pascal Christen <pascal.christen>
Component: Individual Port(s)Assignee: Torsten Zuehlsdorff <tz>
Status: Closed FIXED    
Severity: Affects Some People CC: i.dani, mfburdett, oliver, tz
Priority: --- Flags: bugzilla: maintainer-feedback? (tz)
tz: merge-quarterly+
Version: Latest   
Hardware: Any   
OS: Any   

Description Pascal Christen 2018-11-06 12:37:16 UTC
Hi

We just started to test PHP7.3 on our develpoment Server. Now I get the following issue with PHP7.3 on FreeBSD 11.2:

[#]/usr/local/php73/bin/php index.php 
Bus error (core dumped)

This problem just happens on FreeBSD. I made the same wordpress (default installation with DB-Setup) on Ubuntu 18 with PHP7.3 wihtout any issues.

Can you guys reproduce that?

Setup:

php73-7.3.0.r4                 PHP Scripting Language
php73-bcmath-7.3.0.r4          The bcmath shared extension for php
php73-bz2-7.3.0.r4             The bz2 shared extension for php
php73-calendar-7.3.0.r4        The calendar shared extension for php
php73-ctype-7.3.0.r4           The ctype shared extension for php
php73-curl-7.3.0.r4            The curl shared extension for php
php73-dba-7.3.0.r4             The dba shared extension for php
php73-dom-7.3.0.r4             The dom shared extension for php
php73-exif-7.3.0.r4            The exif shared extension for php
php73-fileinfo-7.3.0.r4        The fileinfo shared extension for php
php73-filter-7.3.0.r4          The filter shared extension for php
php73-ftp-7.3.0.r4             The ftp shared extension for php
php73-gd-7.3.0.r4              The gd shared extension for php
php73-gettext-7.3.0.r4         The gettext shared extension for php
php73-gmp-7.3.0.r4             The gmp shared extension for php
php73-hash-7.3.0.r4            The hash shared extension for php
php73-iconv-7.3.0.r4           The iconv shared extension for php
php73-imap-7.3.0.r4            The imap shared extension for php
php73-intl-7.3.0.r4            The intl shared extension for php
php73-json-7.3.0.r4            The json shared extension for php
php73-ldap-7.3.0.r4            The ldap shared extension for php
php73-mbstring-7.3.0.r4        The mbstring shared extension for php
php73-mysqli-7.3.0.r4          The mysqli shared extension for php
php73-odbc-7.3.0.r4            The odbc shared extension for php
php73-opcache-7.3.0.r4         The opcache shared extension for php
php73-openssl-7.3.0.r4         The openssl shared extension for php
php73-pcntl-7.3.0.r4           The pcntl shared extension for php
php73-pdo-7.3.0.r4             The pdo shared extension for php
php73-pdo_dblib-7.3.0.r4       The pdo_dblib shared extension for php
php73-pdo_mysql-7.3.0.r4       The pdo_mysql shared extension for php
php73-pdo_pgsql-7.3.0.r4       The pdo_pgsql shared extension for php
php73-pdo_sqlite-7.3.0.r4      The pdo_sqlite shared extension for php
php73-pecl-APCu-5.1.12         APC User Caching
php73-pecl-geoip-1.1.1         Map IP address to geographic places
php73-pecl-gnupg-1.4.0_1       PECL wrapper around the gpgme library
php73-pecl-imagick-3.4.3_3     Provides a wrapper to the ImageMagick/GraphicsMagick library
php73-pecl-jsmin-3.0.0         PHP extension for minifying JavaScript
php73-pecl-mailparse-3.0.2     PECL extension to create and decode MIME messages
php73-pecl-mcrypt-1.0.1        PHP extension for mcrypt, removed in PHP 7.2
php73-pecl-mongodb-1.5.2       PECL classes for MongoDB
php73-pecl-pdflib-4.1.2        PECL extension to create PDF on the fly
php73-pecl-scrypt-1.4.2        PHP wrapper to Colin Percival's scrypt implementation
php73-pecl-ssh2-1.1.2          PECL extension to the libssh2 library
php73-pecl-timezonedb-2018.7   Timezone Database to be used with PHP date and time functions
php73-pecl-xdebug-devel-2.7.0.b1 Xdebug extension for PHP
php73-pecl-yaml-2.0.2          YAML-1.1 parser and emitter
php73-pgsql-7.3.0.r4           The pgsql shared extension for php
php73-phar-7.3.0.r4            The phar shared extension for php
php73-posix-7.3.0.r4           The posix shared extension for php
php73-pspell-7.3.0.r4          The pspell shared extension for php
php73-readline-7.3.0.r4        The readline shared extension for php
php73-recode-7.3.0.r4          The recode shared extension for php
php73-session-7.3.0.r4         The session shared extension for php
php73-simplexml-7.3.0.r4       The simplexml shared extension for php
php73-snmp-7.3.0.r4            The snmp shared extension for php
php73-soap-7.3.0.r4            The soap shared extension for php
php73-sockets-7.3.0.r4         The sockets shared extension for php
php73-sqlite3-7.3.0.r4         The sqlite3 shared extension for php
php73-sysvmsg-7.3.0.r4         The sysvmsg shared extension for php
php73-sysvsem-7.3.0.r4         The sysvsem shared extension for php
php73-sysvshm-7.3.0.r4         The sysvshm shared extension for php
php73-tidy-7.3.0.r4            The tidy shared extension for php
php73-tokenizer-7.3.0.r4       The tokenizer shared extension for php
php73-wddx-7.3.0.r4            The wddx shared extension for php
php73-xml-7.3.0.r4             The xml shared extension for php
php73-xmlreader-7.3.0.r4       The xmlreader shared extension for php
php73-xmlrpc-7.3.0.r4          The xmlrpc shared extension for php
php73-xmlwriter-7.3.0.r4       The xmlwriter shared extension for php
php73-xsl-7.3.0.r4             The xsl shared extension for php
php73-zip-7.3.0.r4             The zip shared extension for php
php73-zlib-7.3.0.r4            The zlib shared extension for php


Download wordpress & extract, change wp-config to a working DB and just call the index.php.


Greetings Pascal
Comment 1 Jochen Neumeister freebsd_committer 2018-11-06 13:14:33 UTC
You use the wordpress from the wp site?
When you use the wordpress port (www/wordpress), do you get the same error?
is this error only with wordpress? Or with other CMS? Typo3 for example.
Comment 2 Pascal Christen 2018-11-06 13:19:41 UTC
(In reply to Jochen Neumeister from comment #1)

Yes I used the latest Wordpress from the https://wordpress.org/download/ site,

Let me check other CMS later this week - sorry!
Comment 3 Pascal Christen 2018-11-09 07:39:26 UTC
(In reply to Jochen Neumeister from comment #1)

ok, so:

joomla:
name="return" value="PHP Fatal error:  Allowed memory size of 134217728
bytes exhausted (tried to allocate 12298126926392233984 bytes) in
Unknown on line 0

druapl: segmentation fault

This could be related

https://bugs.php.net/bug.php?id=76560
Comment 4 Jochen Neumeister freebsd_committer 2018-11-09 08:04:13 UTC
(In reply to Pascal Christen from comment #3)

Hi Pascal :-)

Thanks for the testing. Which version did you test it with? The day before yesterday, I committed version RC5. The bug was still with BETA2. I will also build and test a WM at the weekend. Let's hope the PHP developers fix that soon.
Comment 5 Pascal Christen 2018-11-09 08:09:25 UTC
(In reply to Jochen Neumeister from comment #4)

Hi. Just verified it with the RC5. Same problems...
Comment 6 Pascal Christen 2018-11-09 08:41:12 UTC
(In reply to Jochen Neumeister from comment #4)

Just built PHP with debug option and got a trace for the wokrdpress problem:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000599a26 in php_trim_int (str=0x5abb70 <php_addslashes_sse42>, what=0x802a1e658 "/", what_len=1, mode=3) at ext/standard/string.c:811
811	ext/standard/string.c: No such file or directory.
(gdb) bt
#0  0x0000000000599a26 in php_trim_int (str=0x5abb70 <php_addslashes_sse42>, what=0x802a1e658 "/", what_len=1, mode=3) at ext/standard/string.c:811
#1  0x000000000059a247 in php_do_trim (execute_data=0x802c1f750, return_value=0x802c1e950, mode=3) at ext/standard/string.c:903
#2  0x0000000000599e02 in zif_trim (execute_data=0x802c1f750, return_value=0x802c1e950) at ext/standard/string.c:911
#3  0x00000000007fca2d in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER (execute_data=0x802c1e3a0) at Zend/zend_vm_execute.h:690
#4  0x00000000007aeef4 in execute_ex (ex=0x802c1e030) at Zend/zend_vm_execute.h:55287
#5  0x00000000007af0fa in zend_execute (op_array=0x802c7e400, return_value=0x0) at Zend/zend_vm_execute.h:60834
#6  0x0000000000744fc4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at Zend/zend.c:1568
#7  0x000000000069ba9e in php_execute_script (primary_file=0x7fffffffda68) at main/main.c:2630
#8  0x000000000084eda2 in do_cli (argc=4, argv=0x7fffffffe0a0) at sapi/cli/php_cli.c:997
#9  0x000000000084de03 in main (argc=4, argv=0x7fffffffe0a0) at sapi/cli/php_cli.c:1390


Here for the joomla:
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted at /wrkdirs/usr/ports/lang/php73/work/php-7.3.0RC5/Zend/zend_smart_str.c:41 (tried to allocate 13849063123295670240 bytes) in Unknown on line 0
PHP Stack trace:
PHP   1. {main}() /home/myuser/www/myuser.hoster.ch/joomla3/index.php:0
PHP   2. Joomla\CMS\Application\SiteApplication->execute() /home/myuser/www/myuser.hoster.ch/joomla3/index.php:49
PHP   3. Joomla\CMS\Application\SiteApplication->doExecute() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Application/CMSApplication.php:195
PHP   4. Joomla\CMS\Application\SiteApplication->dispatch() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Application/SiteApplication.php:233
PHP   5. Joomla\CMS\Component\ComponentHelper::renderComponent() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Application/SiteApplication.php:194
PHP   6. Joomla\CMS\Component\ComponentHelper::executeComponent() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Component/ComponentHelper.php:357
PHP   7. require_once() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Component/ComponentHelper.php:382
PHP   8. ContentController->execute() /home/myuser/www/myuser.hoster.ch/joomla3/components/com_content/content.php:43
PHP   9. ContentController->display() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/MVC/Controller/BaseController.php:710
PHP  10. ContentController->display() /home/myuser/www/myuser.hoster.ch/joomla3/components/com_content/controller.php:113
PHP  11. ContentViewArticle->display() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/MVC/Controller/BaseController.php:672
PHP  12. ContentViewArticle->get() /home/myuser/www/myuser.hoster.ch/joomla3/components/com_content/views/article/view.html.php:42
PHP  13. ContentModelArticle->getItem() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/MVC/View/HtmlView.php:423
PHP  14. JError::raiseError() /home/myuser/www/myuser.hoster.ch/joomla3/components/com_content/models/article.php:152
PHP  15. JError::raise() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/legacy/error/error.php:277
PHP  16. JError::throwError() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/legacy/error/error.php:202
PHP  17. JError::handleCallback() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/legacy/error/error.php:241
PHP  18. JError::customErrorPage() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/legacy/error/error.php:780
PHP  19. Joomla\CMS\Exception\ExceptionHandler::render() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/legacy/error/error.php:797
PHP  20. Joomla\CMS\Application\SiteApplication->close() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/src/Exception/ExceptionHandler.php:128
PHP  21. JSessionHandlerJoomla->save() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/joomla/session/handler/native.php:0
PHP  22. session_write_close() /home/myuser/www/myuser.hoster.ch/joomla3/libraries/joomla/session/handler/native.php:194
[Inferior 1 (process 67650) exited with code 0377]


Hope this helps to bring us further :)
Comment 7 Jochen Neumeister freebsd_committer 2018-11-10 18:50:26 UTC
(In reply to Pascal Christen from comment #5)

Hey Pascal. Thanks for the testing and the link. I hope the PHP team finds a patch soon. I will keep that in mind. I take the PR to me, because TZ is very busy at the moment.
Comment 8 Pascal Christen 2018-11-12 08:25:44 UTC
(In reply to Jochen Neumeister from comment #7)

Ok thanks. But personally I'm not sure if we're facing the same issue with the "tried to allocate 12298126926392233984 bytes" and the wordpress error (See gdb output in #6). What do you think? related problems or 2 diffrent?
Comment 9 Pascal Christen 2018-12-03 10:49:09 UTC
Do we have any updates on this case? Do you need any additional information?
Comment 10 Torsten Zuehlsdorff freebsd_committer 2018-12-19 08:42:44 UTC
Hello Pascal,

i'm taking over the PR, but most likely i won't have much time until next year for it.

Still lets harvest some important information:
- Does this issue persist after the Release of 7.3.0?
- Is there any PHP Bug entry? 
- Can you provide a new debug trace?

From the trace you already added it looks like a bug in the trim() code. But before digging into the code, i want to make sure nothing had changed since then. :D

Do you know any other user having the same issue? At the moment you are the only one. 

Greetings,
Torsten
Comment 11 Oliver H 2018-12-19 15:18:04 UTC
(In reply to Torsten Zuehlsdorff from comment #10)

Thanks for taking on this report. We have also been seeing this issue, so to answer your questions:

1. Yes, this issue is still there on PHP 7.3 release
2. No PHP bug entry that I can see
3. New stack trace (for WordPress 4.9.9) below. Apologies it isn't compiled with debug on, hope it's still useful. It at least shows that zif_trim is still involved.

Core was generated by `php index.php'.
Program terminated with signal 10, Bus error.
(gdb) bt
#0  0x00000000004d3260 in zif_trim ()
#1  0x0000000000622391 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER ()
#2  0x00000000005d37f8 in execute_ex ()
#3  0x00000000005d39b6 in zend_execute ()
#4  0x000000000058e605 in zend_execute_scripts ()
#5  0x0000000000529dd2 in php_execute_script ()
#6  0x000000000064e889 in do_cli ()
#7  0x000000000064d822 in main ()
#8  0x0000000000423a25 in _start ()
#9  0x00000008009b7000 in ?? ()
#10 0x0000000000000000 in ?? ()


This is on FreeBSD 11.2-RELEASE-p6. PHP was compiled from ports today on our standard poudriere server.
Comment 12 mark burdett 2018-12-26 20:22:45 UTC
I didn't try WordPress but I saw similar issues with another PHP app on FreeBSD 11.2 and PHP 7.3.0

After upgrading to FreeBSD 12.0 the issue was resolved.

See also https://bugs.php.net/bug.php?id=77284
Comment 13 Pascal Christen 2018-12-27 13:12:30 UTC
Still having issues with php7.3 on freebsd 11.2

If you guys also have problem try to push these bugs:
https://bugs.php.net/bug.php?id=77284
https://bugs.php.net/bug.php?id=77279
https://bugs.php.net/bug.php?id=77261

Hope we'll find a solution soon! :)
Comment 15 Torsten Zuehlsdorff freebsd_committer 2019-01-07 11:07:55 UTC
Hello,

from now on i have back a regular time to cope with this issues.

The linked PRs look promising. Just to be sure:

Pascal, you did apply the linked patch and it works?

If so, i will add the patch, so we do not need to wait until the next release.

Greetings,
Torsten
Comment 16 Oliver H 2019-01-07 11:17:32 UTC
(In reply to Torsten Zuehlsdorff from comment #15)

I tried the patch from #14 and can confirm it resolved the problem here. However I don't yet know what (if any) performance impact removing ifunc support has since it's currently a very lightly loaded server.
Comment 17 Pascal Christen 2019-01-07 16:51:55 UTC
(In reply to Torsten Zuehlsdorff from comment #15)

Hi Thorsten

Yes it works but don't know about side effects.

Greetings Pascal
Comment 18 commit-hook freebsd_committer 2019-01-08 15:54:43 UTC
A commit references this bug:

Author: tz
Date: Tue Jan  8 15:54:24 UTC 2019
New revision: 489721
URL: https://svnweb.freebsd.org/changeset/ports/489721

Log:
  lang/php73: Fix "Bus error (core dumped)" by disabling ifuncs

  PHP 7.3 uses ifuncs optimisations which generates a list of problems on FreeBSD:
  https://bugs.php.net/bug.php?id=77284
  https://bugs.php.net/bug.php?id=77279
  https://bugs.php.net/bug.php?id=77261

  Therefore ifuncs will be disabled in PHP 7.3.1. To make it usable until the release,
  we import the patch until then:
  https://github.com/php/php-src/commit/291589114aa9be899cf7d5d874c3b5bbdb35f336

  PR:		233024
  Submitted by:	Pascal Christen <pascal.christen@hostpoint.ch>
  MFH:		2019Q1

Changes:
  head/lang/php73/Makefile
  head/lang/php73/files/patch-acinclude.m4
  head/lang/php73/files/patch-configure.ac
Comment 19 commit-hook freebsd_committer 2019-01-09 07:50:18 UTC
A commit references this bug:

Author: tz
Date: Wed Jan  9 07:49:26 UTC 2019
New revision: 489755
URL: https://svnweb.freebsd.org/changeset/ports/489755

Log:
  MFH: r489721

  lang/php73: Fix "Bus error (core dumped)" by disabling ifuncs

  PHP 7.3 uses ifuncs optimisations which generates a list of problems on FreeBSD:
  https://bugs.php.net/bug.php?id=77284
  https://bugs.php.net/bug.php?id=77279
  https://bugs.php.net/bug.php?id=77261

  Therefore ifuncs will be disabled in PHP 7.3.1. To make it usable until the release,
  we import the patch until then:
  https://github.com/php/php-src/commit/291589114aa9be899cf7d5d874c3b5bbdb35f336

  PR:		233024
  Submitted by:	Pascal Christen <pascal.christen@hostpoint.ch>

  Approved by:	ports-secteam (miwi)

Changes:
_U  branches/2019Q1/
  branches/2019Q1/lang/php73/Makefile
  branches/2019Q1/lang/php73/files/patch-acinclude.m4
  branches/2019Q1/lang/php73/files/patch-configure.ac
Comment 20 Torsten Zuehlsdorff freebsd_committer 2019-01-09 11:15:54 UTC
The patch is committed and merged into quarterly :)