Edit report at https://bugs.php.net/bug.php?id=78303&edit=1
ID: 78303
User updated by: theultramage at gmail dot com
Reported by: theultramage at gmail dot com
Summary: repeating crashes in php_basename with
event-mpm+mod_php
Status: Open
Type: Bug
Package: *General Issues
Operating System: FreeBSD 12.0
PHP Version: 7.3.7
Block user comment: N
Private report: N
New Comment:
mbrlen is available according to config.log.
I dug a bit deeper and found that php's /ext/standard/php_string.h does a weird thing:
#elif defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
# define php_mblen(ptr, len) ((int) mbrlen(ptr, len, &BG(mblen_state)))
Instead of letting configure do the work, it instead relies on an obsolete internal flag
'_REENTRANT'.
Earlier I wasn't specific enough. By 'whatever thread safety flags available' I meant
all the ones supplied by the freebsd ports system. That is, one just adds -lpthread and the other
adds --enable-maintainer-zts and pthreads_working="yes".
Possible scenarios to investigate: clang not automatically defining _REENTRANT. Inclusion of
libpthread not automatically defining _REENTRANT. Header/include ordering issue resulting in
_REENTRANT not propagating properly.
Previous Comments:
------------------------------------------------------------------------
[2019-07-17 09:20:09] nikic@php.net
PHP will use the thread-safe mbrlen() if it is available -- and per https://www.freebsd.org/cgi/man.cgi?query=mbrlen&sektion=3&apropos=0&manpath=FreeBSD+12.0-RELEASE+and+Ports
it should be on FreeBSD. Could you check your config.log to see why the mbrlen check fails?
------------------------------------------------------------------------
[2019-07-17 09:07:04] theultramage at gmail dot com
Description:
------------
All components have been built with whatever thread safety flags were available. However, there
seems to be a multithreading issue in the way freebsd's libc is invoked, resulting in a null
pointer call. This same crash happens randomly, usually once every few days.
#0 0x0000000000000000 in ?? ()
#1 0x0000000800505e28 in mblen (s=0x8042d223b "p", n=1) at
/usr/src/lib/libc/locale/mblen.c:53
#2 0x0000000801663697 in php_basename () from /usr/local/libexec/apache24/libphp7.so
#3 0x000000080166383d in php_basename () from /usr/local/libexec/apache24/libphp7.so
#4 0x00000008017d3de1 in zend_execute () from /usr/local/libexec/apache24/libphp7.so
#5 0x000000080178061b in execute_ex () from /usr/local/libexec/apache24/libphp7.so
#6 0x00000008017808b6 in zend_execute () from /usr/local/libexec/apache24/libphp7.so
#7 0x0000000801733894 in zend_execute_scripts () from /usr/local/libexec/apache24/libphp7.so
#8 0x00000008016c02b9 in php_execute_script () from /usr/local/libexec/apache24/libphp7.so
#9 0x0000000801801808 in zend_check_arg_type () from /usr/local/libexec/apache24/libphp7.so
#10 0x000000000025a5f9 in ap_invoke_handler ()
#11 0x0000000000295c1f in ap_process_async_request ()
#12 0x000000000029254d in ap_process_http_connection ()
#13 0x0000000000272bf9 in ap_run_process_connection ()
#14 0x000000000029fb61 in process_socket ()
#15 0x000000000029f6d7 in worker_thread ()
#16 0x0000000800450767 in thread_start (curthread=0x803153000) at
/usr/src/lib/libthr/thread/thr_create.c:292
set = {__bits = 0x7fffdfdfcfc8}
int mblen(const char *s, size_t n)
{
return mblen_l(s, n, __get_locale());
}
int mblen_l(const char *s, size_t n, locale_t locale)
{
...
rval = XLOCALE_CTYPE(locale)->__mbrtowc(NULL, s, n, &locale->mblen);
...
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78303&edit=1