Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 726962 - dev-util/cmake with dev-libs/libuv-1.37.0 - cmake: segmentation fault when calling uv_loop_close()
Summary: dev-util/cmake with dev-libs/libuv-1.37.0 - cmake: segmentation fault when ca...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Stabilization (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo KDE team
URL:
Whiteboard:
Keywords: CC-ARCHES
Depends on:
Blocks:
 
Reported: 2020-06-03 18:39 UTC by tedheadster
Modified: 2020-12-17 07:47 UTC (History)
2 users (show)

See Also:
Package list:
dev-util/cmake-3.17.4-r1
Runtime testing required: ---
nattka: sanity-check+


Attachments
cmake build log (build.log,785.10 KB, text/plain)
2020-06-03 20:22 UTC, tedheadster
no flags Details
emerge --info cmake (cmake_emerge.txt,4.75 KB, text/plain)
2020-06-03 20:25 UTC, tedheadster
no flags Details
emerge --info libuv (libuv_emerge.txt,4.76 KB, text/plain)
2020-06-03 20:28 UTC, tedheadster
no flags Details
libuv emerge console output (libuv_build.txt,111.88 KB, text/plain)
2020-06-03 20:39 UTC, tedheadster
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description tedheadster 2020-06-03 18:39:48 UTC
cmake 3.16.5 generates a segmentation fault while calling uv_loop_close() (from dev-libs/libuv).

It does this for something as simple as 'cmake --version'.

I tried both libuv versions 1.35.0 and 1.37.0 with the same result.


/var/tmp/portage/dev-util/cmake-3.16.5/image/usr/bin # gdb ./cmake
GNU gdb (Gentoo 9.1 vanilla) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
...
Reading symbols from ./cmake...
(gdb) run --version
Starting program:
/var/tmp/portage/dev-util/cmake-3.16.5/image/usr/bin/cmake --version
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
cmake version 3.16.5

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Program received signal SIGSEGV, Segmentation fault.
0xb7de7296 in uv_loop_close (loop=0x0) at
/usr/src/debug/dev-libs/libuv-1.35.0/libuv-1.35.0/src/uv-common.c:757
757       if (uv__has_active_reqs(loop))
(gdb) up
#1  0x0053fab4 in main (ac=<optimized out>, av=0xb09a60)
    at /var/tmp/portage/dev-util/cmake-3.16.5/work/cmake-3.16.5/Source/cmakemain.cxx:706
706       uv_loop_close(uv_default_loop());
(gdb) up
Initial frame selected; you cannot go up.
(gdb)
Comment 1 Jonas Stein gentoo-dev 2020-06-03 20:04:42 UTC
Thank you for the report. We need to have all information at hand before ticket assignment. That is why I ask you to 
* recompile and attach the logs and 
* paste the emerge info 
as described on https://wiki.gentoo.org/wiki/Attach_the_logs_to_the_bug_ticket
Please reopen this ticket (Status:UNCONFIRMED) afterwards.
Comment 2 tedheadster 2020-06-03 20:22:42 UTC
Created attachment 643318 [details]
cmake build log
Comment 3 tedheadster 2020-06-03 20:25:41 UTC
Created attachment 643320 [details]
emerge --info cmake
Comment 4 tedheadster 2020-06-03 20:28:04 UTC
Created attachment 643322 [details]
emerge --info libuv
Comment 5 tedheadster 2020-06-03 20:39:45 UTC
Created attachment 643328 [details]
libuv emerge console output
Comment 6 tedheadster 2020-06-03 20:42:33 UTC
<begin cmake emerge --info>
Portage 2.3.99 (python 3.7.7-final-0, default/linux/x86/17.0/desktop/gnome/systemd, gcc-9.3.0, glibc-2.30-r8, 4.4.223.pentiumm-laptop i686)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.4.223.pentiumm-laptop-i686-Intel-R-_Pentium-R-_M_processor_1.80GHz-with-gentoo-2.6
KiB Mem:      772596 total,     88188 free
KiB Swap:     523928 total,    514924 free
Timestamp of repository gentoo: Sat, 30 May 2020 16:00:01 +0000
Head commit of repository gentoo: db145202cebf184b2f8131a4e3be5da7ba577765
sh bash 5.0_p17
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
app-shells/bash:          5.0_p17::gentoo
dev-lang/perl:            5.30.1::gentoo
dev-lang/python:          2.7.18::gentoo, 3.7.7-r2::gentoo, 3.8.2-r2::gentoo
dev-util/cmake:           3.9.6::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo
sys-devel/gcc:            9.3.0::gentoo
sys-devel/gcc-config:     2.2.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.30-r8::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-jobs: 1

ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="@FREE"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /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/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN 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="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
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 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="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
GENTOO_MIRRORS="https://mirrors.rit.edu/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j1"
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="X a52 aac acl acpi alsa berkdb bluetooth branding bzip2 cairo cdda cdr cli colord crypt cups dbus dri dts dvd dvdr eds emboss encode evo exif flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk iconv icu introspection ipv6 jpeg lcms ldap libnotify libsecret libtirpc mad mng mp3 mp4 mpeg nautilus ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt5 readline sdl seccomp spell split-usr ssl startup-notification svg systemd tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wxwidgets x264 x86 xattr xcb xml xv xvid zlib" ABI_X86="32" ELIBC="glibc" KERNEL="linux" USERLAND="GNU"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

dev-util/cmake-3.9.6::gentoo was built with the following:
USE="ncurses -doc -emacs -qt5 -server -system-jsoncpp -test"
CHOST="i486-pc-linux-gnu"
CFLAGS="-O2 -march=i486 -pipe"
CXXFLAGS="-O2 -march=i486 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

<end cmake emerge --info>

<begin libuv emerge --info>

Portage 2.3.99 (python 3.7.7-final-0, default/linux/x86/17.0/desktop/gnome/systemd, gcc-9.3.0, glibc-2.30-r8, 4.4.223.pentiumm-laptop i686)
=================================================================
                         System Settings
=================================================================
System uname: Linux-4.4.223.pentiumm-laptop-i686-Intel-R-_Pentium-R-_M_processor_1.80GHz-with-gentoo-2.6
KiB Mem:      772596 total,     88016 free
KiB Swap:     523928 total,    514940 free
Timestamp of repository gentoo: Sat, 30 May 2020 16:00:01 +0000
Head commit of repository gentoo: db145202cebf184b2f8131a4e3be5da7ba577765
sh bash 5.0_p17
ld GNU ld (Gentoo 2.33.1 p2) 2.33.1
app-shells/bash:          5.0_p17::gentoo
dev-lang/perl:            5.30.1::gentoo
dev-lang/python:          2.7.18::gentoo, 3.7.7-r2::gentoo, 3.8.2-r2::gentoo
dev-util/cmake:           3.9.6::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.33.1-r1::gentoo
sys-devel/gcc:            9.3.0::gentoo
sys-devel/gcc-config:     2.2.1::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 5.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.30-r8::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-extra-opts: 

ACCEPT_KEYWORDS="x86"
ACCEPT_LICENSE="@FREE"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /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/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN 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="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
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 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="-O2 -march=pentium-m -pipe -ggdb -frecord-gcc-switches"
GENTOO_MIRRORS="https://mirrors.rit.edu/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j1"
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="X a52 aac acl acpi alsa berkdb bluetooth branding bzip2 cairo cdda cdr cli colord crypt cups dbus dri dts dvd dvdr eds emboss encode evo exif flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk iconv icu introspection ipv6 jpeg lcms ldap libnotify libsecret libtirpc mad mng mp3 mp4 mpeg nautilus ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt5 readline sdl seccomp spell split-usr ssl startup-notification svg systemd tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wxwidgets x264 x86 xattr xcb xml xv xvid zlib" ABI_X86="32" ELIBC="glibc" KERNEL="linux" USERLAND="GNU"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

dev-libs/libuv-1.37.0::gentoo was built with the following:
USE="-static-libs"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg compressdebug config-protect-if-modified distlocks ebuild-locks fixlafiles installsources ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"

<end libuv emerge --info>
Comment 7 Jeroen Roovers (RETIRED) gentoo-dev 2020-06-03 21:33:45 UTC
(In reply to Jonas Stein from comment #1)
> We need to have all information at hand before ticket assignment.

No, we don't.
Comment 8 Jeroen Roovers (RETIRED) gentoo-dev 2020-06-03 21:43:10 UTC
(In reply to tedheadster from comment #6)
> <begin cmake emerge --info>
> Portage 2.3.99 (python 3.7.7-final-0,
> default/linux/x86/17.0/desktop/gnome/systemd, gcc-9.3.0, glibc-2.30-r8,
> 4.4.223.pentiumm-laptop i686)
> =================================================================
>                          System Settings
> =================================================================
> System uname:
> Linux-4.4.223.pentiumm-laptop-i686-Intel-R-_Pentium-R-_M_processor_1.80GHz-
> with-gentoo-2.6
> KiB Mem:      772596 total,     88188 free
> KiB Swap:     523928 total,    514924 free

That is not a lot of RAM.
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2020-06-03 21:43:53 UTC
Comment on attachment 643318 [details]
cmake build log

> make: *** [Makefile:74: install] Segmentation fault

That is not a segmentation fault in cmake or in libuv.
Comment 10 tedheadster 2020-06-03 21:53:19 UTC
(In reply to Jeroen Roovers from comment #9)
> Comment on attachment 643318 [details]
> cmake build log
> 
> > make: *** [Makefile:74: install] Segmentation fault
> 
> That is not a segmentation fault in cmake or in libuv.

That message is not the segmentation fault I was referring to. 

It faults when I run '/usr/bin/cmake --version' and also on the newly built binary run the same way.
Comment 11 tedheadster 2020-06-04 16:14:45 UTC
I figured most of this out. 

A patch checking the return code of uv_default_loop() (in Source/cmakemain.cxx line 709) would probably fix it.

The problem is in Source/cmakemain.cxx where it does not check for a returned error code from uv_default_loop(). 

uv_default_loop() returns an error code and the 'uv_loop_t* loop' parameter to uv_loop_close() is still set to NULL.

705       int ret = do_cmake(ac, av);
706     #ifndef CMAKE_BOOTSTRAP
707       cmDynamicLoader::FlushCache();
708     #endif
709       uv_loop_close(uv_default_loop()); <---- no error code checking
710       return ret;
711     }

uv_default_loop() calls up_loop_init().

In uv_loop_init()  (libuv-1.37.0/src/unix/loop.c) line 88 it gets an error (-38) and it jumps to the fail_async_init() error handler:

88        err = uv_async_init(loop, &loop->wq_async, uv__work_done);
89        if (err) <---- An error is returned
90          goto fail_async_init; <---- Jump to error handler
91
(gdb) next
89        if (err)
(gdb) print err 
$24 = -38

I will investigate the error code, but it cmake should not assume that the call to uv_default_loop() will always be successful.
Comment 12 tedheadster 2020-07-01 16:48:25 UTC
To reproduce this bug, run with a kernel without CONFIG_EVENTFD enabled.

You must check the return code of uv_default_loop() and not presume it is always successful.
Comment 13 Jeroen Roovers (RETIRED) gentoo-dev 2020-07-01 17:17:19 UTC
It looks like this problem is not specific to Gentoo Linux. Did you report this upstream yet?


https://gitlab.kitware.com/cmake/cmake/-/issues
Comment 14 tedheadster 2020-07-01 20:04:55 UTC
Upstream now has an issue created.

https://gitlab.kitware.com/cmake/cmake/-/issues/20899
Comment 15 Larry the Git Cow gentoo-dev 2020-09-06 16:46:16 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=756046b3193fbc055435914b252bed4eabf3c766

commit 756046b3193fbc055435914b252bed4eabf3c766
Author:     Andreas Sturmlechner <asturm@gentoo.org>
AuthorDate: 2020-09-05 16:10:47 +0000
Commit:     Andreas Sturmlechner <asturm@gentoo.org>
CommitDate: 2020-09-06 16:45:36 +0000

    dev-util/cmake: Tolerate nullptr from uv_default_loop
    
    See also: https://discourse.cmake.org/t/cmake-3-16-5-segmentation-violation/1316
    
    Thanks-to: <tedheadster@gmail.com>
    Bug: https://bugs.gentoo.org/726962
    Package-Manager: Portage-3.0.5, Repoman-3.0.1
    Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>

 ...{cmake-3.17.4.ebuild => cmake-3.17.4-r1.ebuild} |  1 +
 .../cmake/files/cmake-3.17.4-uv-check-return.patch | 46 ++++++++++++++++++++++
 2 files changed, 47 insertions(+)
Comment 16 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-09-29 22:16:34 UTC
arm64 done
Comment 17 Sergei Trofimovich (RETIRED) gentoo-dev 2020-10-02 10:02:00 UTC
ppc/ppc64 stable
Comment 18 Rolf Eike Beer archtester 2020-10-02 16:47:01 UTC
sparc stable
Comment 19 Sergei Trofimovich (RETIRED) gentoo-dev 2020-10-03 09:20:28 UTC
hppa stable
Comment 20 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-10-04 16:52:32 UTC
amd64 done
Comment 21 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-10-06 20:52:33 UTC
arm done
Comment 22 Agostino Sarubbo gentoo-dev 2020-10-09 08:41:44 UTC
x86 stable
Comment 23 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-12-17 07:47:50 UTC
s390 done

all arches done