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 librt-2.32.so
Summary: dev-php/xdebug-3.0.1 crashes dev-lang/php-7.4.11: segfault in librt-2.32.so
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: PHP Bugs
URL: https://bugs.xdebug.org/view.php?id=1934
Whiteboard:
Keywords:
: 770919 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-12-13 17:38 UTC by sphakka
Modified: 2022-02-23 23:48 UTC (History)
6 users (show)

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


Attachments

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 $?
  139

Dmesg says:

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

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

  zend_extension=/usr/lib64/php7.4/lib/extensions/no-debug-zts-20190902/xdebug.so

Reproducible: Always

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

  zend_extension=/usr/lib64/php7.4/lib/extensions/no-debug-zts-20190902/xdebug.so
  xdebug.mode=off

(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
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/sync/gentoo.git
    priority: -1000

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

bubba
    location: /var/lib/layman/bubba
    sync-type: laymansync
    sync-uri: https://github.com/gordonb3/bubba-overlay.git
    masters: gentoo
    priority: 50

Installed sets: @audio, @dev, @emacs, @emul, @fonts, @gkrellm, @graphix, @net, @office, @utilz, @video, @web, @webdev, @xfce
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=haswell -pipe -O2 -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
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"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
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"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
INSTALL_MASK="/usr/lib/systemd/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS=""
MAKEOPTS="-j9"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
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"
PORTAGE_TMPDIR="/var/tmp"
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"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        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/libthread_db.so.1".
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 (RETIRED) 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):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2c042fa36660036a959231eb89a7b5c822792de9

commit 2c042fa36660036a959231eb89a7b5c822792de9
Author:     Brian Evans <grknight@gentoo.org>
AuthorDate: 2021-02-16 15:03:11 +0000
Commit:     Brian Evans <grknight@gentoo.org>
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
    
    Closes: https://bugs.gentoo.org/759835
    Signed-off-by: Brian Evans <grknight@gentoo.org>

 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:

  https://www.php.net/manual/en/install.unix.apache2.php

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.)
Comment 10 Alex Barker 2021-03-02 07:27:35 UTC
> 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.

I don't think this has a whole lot to do with an MPM and more to do with CLI extensions like pecl parallel.  See: https://github.com/krakjoe/parallel/blob/develop/INSTALL.md
Comment 11 Alex Barker 2021-03-02 07:33:05 UTC
> (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.)

I have only been able to reproduce this bug on Gentoo, this doesn't seem to be a problem with debian or any of the docker containers I've tried so I am starting to suspect that the issue maybe outside of PHP/XDebug.
Comment 12 Thomas Deutschmann (RETIRED) gentoo-dev 2021-03-02 11:57:26 UTC
Could you please describe how to reproduce the problem in clean stage3 (chroot)?
Comment 13 Alex Barker 2021-03-03 01:01:00 UTC
(In reply to Thomas Deutschmann from comment #12)
> Could you please describe how to reproduce the problem in clean stage3
> (chroot)?

This gets it to show up every time:


wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20210228T214502Z/stage3-amd64-nomultilib-20210228T214502Z.tar.xz
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner

cat << EOF > etc/portage/make.conf
COMMON_FLAGS="-march=x86-64 -O2 -ggdb -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"

LC_MESSAGES=C

ACCEPT_KEYWORDS="~amd64"
ACCEPT_LICENSE="*"
MAKEOPTS="-j16"
PHP_TARGETS="php7-3"
PORTDIR_OVERLAY="/usr/local/portage"
USE="curl threads"
EOF

mkdir --parents etc/portage/repos.conf
cp usr/share/portage/config/repos.conf etc/portage/repos.conf/gentoo.conf

cp --dereference /etc/resolv.conf etc/

mount --types proc /proc proc
mount --rbind /sys sys
mount --make-rslave sys
mount --rbind /dev dev
mount --make-rslave dev

chroot . /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"


emerge-webrsync

mkdir --parents /usr/local/portage/dev-php
cp -Rvf /var/db/repos/gentoo/dev-php/xdebug /usr/local/portage/dev-php
find /usr/local/portage/dev-php/xdebug -name '*.ebuild' -exec sed '/PHP_EXT_NEEDED_USE="-threads(-)"/d' -i  {} \;
( cd /usr/local/portage/dev-php/xdebug ; ebuild $(ls -t *.ebuild | tail -1) digest )

emerge -v xdebug


PHP 7.3.27 (cli) (built: Mar  3 2021 00:58:18) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.27, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans
Segmentation fault
Comment 14 Alex Barker 2021-03-03 01:12:03 UTC
there should be a php -v after emerge -v xdebug.
Comment 15 Alex Barker 2021-03-03 01:21:31 UTC
probably also want FEATURES="parallel-fetch nostrip" in the make.conf
Comment 16 Alex Barker 2021-03-03 06:29:53 UTC
So I was doing some more digging, and it seems that this not longer crashes when USE=debug is used with PHP... Yah, I have no idea why but if I build `USE="debug" emerge -av1 php:7.3 xdebug` everything works as expected.
Comment 17 segmentation fault 2022-02-20 22:23:00 UTC
(In reply to Larry the Git Cow from comment #7)
> The bug has been closed via the following commit(s):
> 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/
> ?id=2c042fa36660036a959231eb89a7b5c822792de9
> 
> commit 2c042fa36660036a959231eb89a7b5c822792de9
> Author:     Brian Evans <grknight@gentoo.org>
> AuthorDate: 2021-02-16 15:03:11 +0000
> Commit:     Brian Evans <grknight@gentoo.org>
> 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
>     
>     Closes: https://bugs.gentoo.org/759835
>     Signed-off-by: Brian Evans <grknight@gentoo.org>
> 
>  dev-php/xdebug/xdebug-3.0.2-r1.ebuild | 58
> +++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)

If anybody has upgraded xdebug from an old version and now wonders why portage is suddenly asking to add -threads to both php and apache, then the above is the answer. It looks very contradicting:

The following USE changes are necessary to proceed:
...
# required by dev-php/xdebug-3.1.1::gentoo[php_targets_php7-3]
# required by dev-php/phpcov-5.0.0::gentoo
...
>=dev-lang/php-7.3.32:7.3 -threads
...
# required by dev-lang/php-7.3.32::gentoo[apache2]
# required by dev-php/xdebug-3.1.1::gentoo[php_targets_php7-3]
# required by dev-php/phpcov-5.0.0::gentoo
...
>=www-servers/apache-2.4.52 -threads

Would you like to add these changes to your config files? [Yes/No] n

!!! The ebuild selected to satisfy "www-servers/apache[apache2_modules_unixd(+),threads=]" has unmet requirements.

  The following REQUIRED_USE flag constraints are unsatisfied:
    apache2_mpms_event? ( threads )


That is, you have set "event" and "threads", but now it wants to take threads away, but complains that "event" needs them...he? :-)

But once you read the above, it becomes clear that the requirement for -threads comes from xdebug. I guess that's life, if one needs xdebug (like me)...

I found the explanations here very illuminating - thank you very much.
Comment 18 Giuseppe Foti 2022-02-21 21:15:51 UTC
(In reply to segmentation fault from comment #17)
> (In reply to Larry the Git Cow from comment #7)
> > The bug has been closed via the following commit(s):
> > 
> > https://gitweb.gentoo.org/repo/gentoo.git/commit/
> > ?id=2c042fa36660036a959231eb89a7b5c822792de9
> > 
> > commit 2c042fa36660036a959231eb89a7b5c822792de9
> > Author:     Brian Evans <grknight@gentoo.org>
> > AuthorDate: 2021-02-16 15:03:11 +0000
> > Commit:     Brian Evans <grknight@gentoo.org>
> > 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
> >     
> >     Closes: https://bugs.gentoo.org/759835
> >     Signed-off-by: Brian Evans <grknight@gentoo.org>
> > 
> >  dev-php/xdebug/xdebug-3.0.2-r1.ebuild | 58
> > +++++++++++++++++++++++++++++++++++
> >  1 file changed, 58 insertions(+)
> 
> If anybody has upgraded xdebug from an old version and now wonders why
> portage is suddenly asking to add -threads to both php and apache, then the
> above is the answer. It looks very contradicting:
> 
> The following USE changes are necessary to proceed:
> ...
> # required by dev-php/xdebug-3.1.1::gentoo[php_targets_php7-3]
> # required by dev-php/phpcov-5.0.0::gentoo
> ...
> >=dev-lang/php-7.3.32:7.3 -threads
> ...
> # required by dev-lang/php-7.3.32::gentoo[apache2]
> # required by dev-php/xdebug-3.1.1::gentoo[php_targets_php7-3]
> # required by dev-php/phpcov-5.0.0::gentoo
> ...
> >=www-servers/apache-2.4.52 -threads
> 
> Would you like to add these changes to your config files? [Yes/No] n
> 
> !!! The ebuild selected to satisfy
> "www-servers/apache[apache2_modules_unixd(+),threads=]" has unmet
> requirements.
> 
>   The following REQUIRED_USE flag constraints are unsatisfied:
>     apache2_mpms_event? ( threads )
> 
> 
> That is, you have set "event" and "threads", but now it wants to take
> threads away, but complains that "event" needs them...he? :-)
> 
> But once you read the above, it becomes clear that the requirement for
> -threads comes from xdebug. I guess that's life, if one needs xdebug (like
> me)...
> 
> I found the explanations here very illuminating - thank you very much.

This is exactly what I am experiencing now. At the end, I had to mask xdebug-3.1.1 and stay with xdebug-2.9.6.
Is there any solution to upgrade xdebug using MPM "event"? Moving to prefork doesn't allow module http2, and I don't think it is an option (for me).
Comment 19 Brian Evans (RETIRED) gentoo-dev 2022-02-22 14:07:34 UTC
(In reply to Giuseppe Foti from comment #18)
> (In reply to segmentation fault from comment #17)

> > That is, you have set "event" and "threads", but now it wants to take
> > threads away, but complains that "event" needs them...he? :-)
> > 
> > But once you read the above, it becomes clear that the requirement for
> > -threads comes from xdebug. I guess that's life, if one needs xdebug (like
> > me)...
> > 
> > I found the explanations here very illuminating - thank you very much.
> 
> This is exactly what I am experiencing now. At the end, I had to mask
> xdebug-3.1.1 and stay with xdebug-2.9.6.
> Is there any solution to upgrade xdebug using MPM "event"? Moving to prefork
> doesn't allow module http2, and I don't think it is an option (for me).

As already stated in Comment 9, using mod_php with any threaded MPM is discouraged by the PHP project.  The recommended way is to get php-fpm running instead which can solve this issue of no threads and xdebug by removing the apache2 USE on PHP.  This will impact configurations and stop long running pages (which is often poor design) from working due to the nature of FPM timeout.
Comment 20 segmentation fault 2022-02-23 06:26:25 UTC
(In reply to Giuseppe Foti from comment #18)

> Is there any solution to upgrade xdebug using MPM "event"? Moving to prefork
> doesn't allow module http2, and I don't think it is an option (for me).

Maybe you can try this:

Take the ebuild of dev-php/xdebug-3.1.1 and put it into a local overlay of yours. Then revert the change done by above commit 2c042fa36660036a959231eb89a7b5c822792de9. This should have the effect of not blocking threaded PHP anymore.

Then rebuild your PHP with the xdebug extension *and* with the 'debug' USE flag set. 

Merge both your modified xdebug ebuild and your PHP and try the command line (CLI) of PHP. If it does not segfault immediately, then maybe you can work with it. 

I didn't try it, but I base it on the observation done in comment #16.

Maybe the upstream developer could not reproduce it because developers usually have debug functionality enabled. I would also expect xdebug to need some "debug" features of PHP (probably not checking their existence before trying to use them, leading to the observed segmentation faults).

If this works, then the solution might be to require the 'debug' USE flag of PHP to be set, if one merges xdebug.