Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 759835 - dev-php/xdebug-3.0.1 crashes dev-lang/php-7.4.11: segfault in
Summary: dev-php/xdebug-3.0.1 crashes dev-lang/php-7.4.11: segfault in
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: PHP Bugs
: 770919 (view as bug list)
Depends on:
Reported: 2020-12-13 17:38 UTC by sphakka
Modified: 2021-02-24 00:04 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description sphakka 2020-12-13 17:38:46 UTC
It looks like dev-php/xdebug-3.0.1 (upgraded from v2.9.8) makes php-7.4 sick:

  $ php -v
  PHP 7.4.11 (cli) (built: Dec 10 2020 21:17:13) ( ZTS )
  Copyright (c) The PHP Group
  Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
    with Xdebug v3.0.1, Copyright (c) 2002-2020, by Derick Rethans
  Segmentation fault
  $ echo $?

Dmesg says:

  php[10648]: segfault at 7f0da40e2640 ip 00007f0da40e2640 sp 00007ffc981ea438 error 14 in[7f0da412a000+2000]
  Code: Bad RIP value.

The offending line in '/etc/php/cli-php7.4/ext/xdebug.ini':


Reproducible: Always

Steps to Reproduce:
1. Upgrade xdebug to 3.0.1
3. Add in '/etc/php/cli-php7.4/ext/xdebug.ini':


(anything else commented out)

3. Run `php -v` 
Actual Results:  
php crashes with segfault.

Expected Results:  
Normal php execution.

Portage 3.0.9 (python 3.7.9-final-0, default/linux/amd64/17.1/no-multilib, gcc-9.3.0, glibc-2.32-r2, 5.4.80-gentoo-r1 x86_64)
                         System Settings
System uname: Linux-5.4.80-gentoo-r1-x86_64-Intel-R-_Core-TM-_i7-4702MQ_CPU_@_2.20GHz-with-gentoo-2.7
KiB Mem:    16108280 total,   9875880 free
KiB Swap:   16777212 total,  16761368 free
Timestamp of repository gentoo: Fri, 11 Dec 2020 17:35:11 +0000
Head commit of repository gentoo: 284d31ef7d43c643f5ca6beea0730210feaad09c

sh bash 5.0_p18
ld GNU ld (Gentoo 2.34 p6) 2.34.0
app-shells/bash:          5.0_p18::gentoo
dev-lang/perl:            5.30.3::gentoo
dev-lang/python:          2.7.18-r4::gentoo, 3.6.12::gentoo, 3.7.9::gentoo, 3.8.6::gentoo, 3.9.0::gentoo
dev-util/cmake:           3.17.4-r1::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.42.1::gentoo
sys-apps/sandbox:         2.20::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.2-r1::gentoo
sys-devel/binutils:       2.34-r2::gentoo
sys-devel/gcc:            9.3.0-r1::gentoo
sys-devel/gcc-config:     2.3.2-r1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.32-r2::gentoo

    location: /var/db/repos/gentoo
    sync-type: git
    priority: -1000

    location: /var/db/repos/overlay/localrepo
    masters: gentoo
    priority: 10

    location: /var/lib/layman/bubba
    sync-type: laymansync
    masters: gentoo
    priority: 50

Installed sets: @audio, @dev, @emacs, @emul, @fonts, @gkrellm, @graphix, @net, @office, @utilz, @video, @web, @webdev, @xfce
CFLAGS="-march=haswell -pipe -O2 -fomit-frame-pointer"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.4/ext-active/ /etc/php/cgi-php7.4/ext-active/ /etc/php/cli-php7.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=haswell -pipe -O2 -fomit-frame-pointer"
FCFLAGS="-march=haswell -pipe -O2 -fomit-frame-pointer"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch parallel-install pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=haswell -pipe -O2 -fomit-frame-pointer"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
USE="alsa amd64 apng berkdb bittorrent bluetooth btrfs bzip2 calendar caps cddb cdparanoia clang cli corefonts crypt cups curl cvs dbus device-mapper djvu dri dvd dynamic-loading ebook elogind emacs eme-free enchant fam fbcon fortran fpm gdbm git glamor gnome-keyring gnutls gpm graphicsmagick gtk3 gtkstyle gui h323 hddtemp heif http hunspell iconv icu id3tag imagemagick introspection jabber jpeg kpathsea ladspa laptop latex lcms libglvnd libnotify libsamplerate libtirpc lm_sensors lto luks1_default mng mp3 mplayer musepack musicbrainz mysql mysqli ncurses networkmanager nls nptl ntfs ntfsprogs objc objc++ ogg openmp openvg opus pam pcre pgo png policykit postscript ppds python3 readline rtmp scanner sdl seamonkey seccomp split-usr sql sqlite sqlitessh ssl system-av1 system-bootstrap system-cmark system-crontab system-ffmpeg system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-libyaml system-llvm system-mesa system-sqlite system-ssl system-webp system-zlib tcpd threads tordns truetype udisks unicode v4l v4l2 video vlc vorbis wavpack xattr xcb xcomposite xetex xfce xfs xkb xmp xorg xvfb zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="hda-intel usb-audio" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_8" PYTHON_TARGETS="python2_7 python3_8 python3_7" RUBY_TARGETS="ruby25 ruby26" SANE_BACKENDS="epson2 epkowa hp" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

                        Package Settings

dev-php/xdebug-3.0.1::gentoo was built with the following:
USE="" PHP_TARGETS="php7-4 -php7-2 -php7-3 -php8-0"
Comment 1 Niko E 2020-12-30 00:05:43 UTC
I can confirm this. Here is a gdb trace:

$ gdb -q php
Reading symbols from php...
Reading symbols from /usr/lib/debug//usr/lib64/php7.4/bin/php.debug...
(gdb) run -v
Starting program: /usr/bin/php -v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/".
PHP 7.4.13 (cli) (built: Dec 30 2020 00:28:35) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies
    with Xdebug v3.0.1, Copyright (c) 2002-2020, by Derick Rethans

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff427b640 in ?? ()
(gdb) bt
#0  0x00007ffff427b640 in ?? ()
#1  0x0000555555a97f0e in tsrm_shutdown ()
    at /var/tmp/portage/dev-lang/php-7.4.13/work/sapis-build/cli/TSRM/TSRM.c:215
#2  0x00005555557a5975 in main (argc=2, argv=0x5555569900a0)
    at /var/tmp/portage/dev-lang/php-7.4.13/work/sapis-build/cli/sapi/cli/php_cli.c:1380
Comment 2 Michael Orlitzky gentoo-dev 2021-01-15 15:00:09 UTC
This is ultimately due to USE=threads on dev-lang/php itself. I can reproduce it easily now and have reported the problem upstream at $url.
Comment 3 Michael Orlitzky gentoo-dev 2021-01-24 13:43:00 UTC
Upstream doesn't seem very interested in helping us solve this, and I don't use xdebug personally. Unless you're interested in digging through the code to debug it yourself, my practical suggestion is to set USE="-threads" on dev-lang/php. The thread-safety is discouraged (and disabled by default) on production environments anyway since it causes performance problems.

If no one comes up with a better solution, we may force php[-threads] in xdebug to avoid the crash.
Comment 4 sphakka 2021-01-25 08:15:01 UTC
Fair enough! Meanwhile, maybe a pre/post-build message when USE=thread is enabled would help ^^
Comment 5 PF4Public 2021-02-08 16:41:23 UTC
Still happens with Xdebug v3.0.2
Comment 6 Brian Evans Gentoo Infrastructure gentoo-dev 2021-02-16 14:47:48 UTC
*** Bug 770919 has been marked as a duplicate of this bug. ***
Comment 7 Larry the Git Cow gentoo-dev 2021-02-16 15:05:15 UTC
The bug has been closed via the following commit(s):

commit 2c042fa36660036a959231eb89a7b5c822792de9
Author:     Brian Evans <>
AuthorDate: 2021-02-16 15:03:11 +0000
Commit:     Brian Evans <>
CommitDate: 2021-02-16 15:03:11 +0000

    dev-php/xdebug: Revbump to block threaded PHP which segfaults
    If this is fixed upstream, we can remove the restriction
    Signed-off-by: Brian Evans <>

 dev-php/xdebug/xdebug-3.0.2-r1.ebuild | 58 +++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
Comment 8 Alex Barker 2021-02-16 17:18:39 UTC
I wouldn't call this resolved / fixed... disabling threads is going to cause other problems but I'll file another bug when this gets fixed upstream.
Comment 9 Michael Orlitzky gentoo-dev 2021-02-24 00:04:57 UTC
(In reply to Alex Barker from comment #8)
> I wouldn't call this resolved / fixed... disabling threads is going to cause
> other problems but I'll file another bug when this gets fixed upstream.

Disabling USE=threads doesn't disable threads, exactly. When you enable that flag, it tries to make PHP itself thread-safe by passing --enable-maintainer-zts to PHP's ./configure script. That is so PHP can then be run by something that does use threads -- namely your web server, if you happen to use apache with a threaded MPM.

Sadly even that has never worked well. PHP makes use many third-party libraries and extensions that aren't thread safe no matter what you do. So even if you set USE=threads, you'll sometimes get weird crashes and data corruption if you try to use a threaded MPM to run PHP under apache. This is in big red letters on the PHP website:

While the freedom to shoot yourself in the foot is often nice, I think we've been too liberal with this option. You should really be using the prefork or ITK (even better) MPM if you're using mod_php in apache. Anything else is asking for subtle, hard-to-diagnose trouble. And, once you're using a non-threaded MPM, passing --enable-maintainer-zts just kills your performance for no benefit.

(Upstream closed my bug since the developer assigned to it couldn't reproduce the problem. If anyone can figure out how to reproduce it on his machine, he might reconsider.)