Bug#964458: checkinstall: causes segfault of cmake
Package: checkinstall Version: 1.6.2+git20170426.d24a630-3 Followup-For: Bug #964458 Actually the 0014-fix-xstat64.patch already tries to fix this, but applies the fix too late in the function. If it was reworked to move the new code up ~10 lines (to before the "real" mode check), then it would run before the code that's crashing.
Bug#964458: checkinstall: causes segfault of cmake
Dear Maintainer, tried to have a look and it seems that installwatch.so's initialize function was not yet called. Attached are some details and a patch trying to call initialize just before the call to true_xstat64. Another patch would add a build-id to the shared object, so the build process can create a debug symbol package. Kind regards, Bernhard Location just before we end up with eip=0: (rr) reverse-stepi 0xb7edd1d8 in __xstat64 (version=, pathname=, info=) at installwatch.c:3731 3731result=true_xstat64(version,pathname,info); 1: x/i $pc => 0xb7edd1d8 <__xstat64+88>: jmp*%eax (rr) print true_xstat64 $1 = (int (*)(int, const char *, struct stat64 *)) 0x0 Description: Force initialize for xstat64 Author: Bernhard Übelacker Bug-Debian: https://bugs.debian.org/964458 Forwarded: no Last-Update: 2020-08-15 Index: checkinstall-1.6.2+git20170426.d24a630/installwatch/installwatch.c === --- checkinstall-1.6.2+git20170426.d24a630.orig/installwatch/installwatch.c +++ checkinstall-1.6.2+git20170426.d24a630/installwatch/installwatch.c @@ -3728,6 +3728,8 @@ int __xstat64(int version,const char *pa /* We were asked to work in "real" mode */ if( !(__instw.gstatus & INSTW_INITIALIZED) || !(__instw.gstatus & INSTW_OKWRAP) ) { + if (!true_xstat64) + initialize(); result=true_xstat64(version,pathname,info); return result; } Description: Add build-id to enable automatic generation of dbgsym package. Author: Bernhard Übelacker Forwarded: no Last-Update: 2020-08-15 Index: checkinstall-1.6.2+git20170426.d24a630/installwatch/Makefile === --- checkinstall-1.6.2+git20170426.d24a630.orig/installwatch/Makefile +++ checkinstall-1.6.2+git20170426.d24a630/installwatch/Makefile @@ -16,7 +16,7 @@ LIBDIR=$(PREFIX)/lib all: installwatch.so installwatch.so: installwatch.o - ld -znow -shared -o installwatch.so installwatch.o -ldl -lc + ld -znow -shared --build-id -o installwatch.so installwatch.o -ldl -lc installwatch.o: installwatch.c localdecls.h gcc $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Wall -c -g -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT -DVERSION=\"$(VERSION)\" installwatch.c # Unstable i386 qemu VM 2020-08-14 apt update apt dist-uprade apt install systemd-coredump gdb git fakeroot mc checkinstall libgnutls30-dbgsym apt build-dep libgnutls30 apt build-dep rr apt build-dep checkinstall echo 1 > /proc/sys/kernel/perf_event_paranoid mkdir /home/benutzer/source/libgnutls30/orig -p cd/home/benutzer/source/libgnutls30/orig apt source libgnutls30 cd # unfortunately no checkinstall-dbgsym package available ... mkdir /home/benutzer/source/checkinstall/orig -p cd/home/benutzer/source/checkinstall/orig apt source checkinstall cd cd /home/benutzer/source/checkinstall cp orig try1 -a cd try1/checkinstall-1.6.2+git20170426.d24a630/ DEB_BUILD_OPTIONS=nostrip dpkg-buildpackage dpkg -i /home/benutzer/source/checkinstall/try1/checkinstall_1.6.2+git20170426.d24a630-2_i386.deb mkdir /home/benutzer/source/rr/git -p cd/home/benutzer/source/rr/git git clone https://github.com/mozilla/rr.git cd cd /home/benutzer/source/rr/git/rr/ mkdir obj && cd obj cmake ../rr make -j4 touch CMakeLists.txt cmake . installwatch cmake . $ installwatch cmake . INFO : Using a default root directory : /tmp/tmp.2yZ1I6G54F /usr/bin/installwatch: Zeile 338: 3465 Speicherzugriffsfehler (Speicherabzug geschrieben) "$@" dmesg: [Sa Aug 15 01:32:54 2020] cmake[3465]: segfault at 0 ip sp bfd2951c error 14 in cmake[4bf000+1] [Sa Aug 15 01:32:54 2020] Code: Bad RIP value. root@debian:~# coredumpctl list TIMEPID UID GID SIG COREFILE EXE Sat 2020-08-15 01:32:55 CEST 3465 1000 1000 11 present /usr/bin/cmake root@debian:~# coredumpctl gdb 3465 ... Core was generated by `cmake .'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x in ?? () (gdb) bt #0 0x in ?? () #1 0xb6a59c13 in ?? () from /usr/lib/i386-linux-gnu/libgnutls.so.30 #2 0xb6a6d535 in ?? () from /usr/lib/i386-linux-gnu/libgnutls.so.30 #3 0xb6a3f990 in ?? () from /usr/lib/i386-linux-gnu/libgnutls.so.30 #4 0xb7f3be9c in call_init (l=, argc=argc@entry=2, argv=argv@entry=0xbfd29694, env=0xbfd296a0) at dl-init.c:72 #5 0xb7f3bfa2 in call_init (env=0xbfd296a0, argv=0xbfd29694, argc=2, l=) at dl-init.c:30 #6 _dl_init (main_map=, argc=2, argv=0xbfd29694, env=0xbfd296a0) at dl-init.c:119 #7 0xb7f2c0fa in _dl_start_user () from /lib/ld-linux.so.2 (gdb) bt #0 0x in ?? () #1 0xb6a59c13 in stat64 (__statbuf=, __path=0xb6b572bb "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 #2 _gnutls_update_system_priorities () at ../../lib/priority.c:1309 #3 0xb6a6d535 in _gnutls_global_init (constructor=constructor@entry=1) at ../../lib/global.c:3
Bug#964458: checkinstall: causes segfault of cmake
Perfect, thanks. I will take a look and see what I can do. I will warn you that the original developer of checkinstall doesn't seem interested in the project anymore so any fix will be limited to anything I or any other Debian contributor can figure out so no promises that this will be able to be fixed promptly. Stephen On Tue, Jul 7, 2020 at 7:30 PM Jiri Palecek wrote: > > Hello, > > On 07. 07. 20 17:11, Stephen Gelman wrote: > > On Jul 7, 2020, at 9:42 AM, Jiri Palecek wrote: > >> Package: checkinstall > >> Version: 1.6.2+git20170426.d24a630-2 > >> Severity: important > >> File: /usr/bin/installwatch > >> > >> Dear Maintainer, > >> > >> while trying to use checkinstall to create a debianized package from a > >> cmake based source, the build failed with a segfault. These are linked > >> to installwatch and don't happen without it: > >> > >> $ installwatch make cmake_check_build_system > >> > >> INFO : Using a default root directory : /tmp/tmp.JBpq66zd4H > >> > >> make: *** [Makefile:10806: cmake_check_build_system] Neoprávněný přístup > >> do paměti (SIGSEGV) (obraz paměti uložen) > >> > >> There is a backtrace of the crash, which indicates it happens early in > >> the initialization of cmake around a stat call: > >> > >> (gdb) bt > >> #0 0x in ?? () > >> #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb > >> "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 > >> #2 _gnutls_update_system_priorities () at ../../lib/priority.c:1309 > >> #3 0xb6a534f5 in _gnutls_global_init (constructor=constructor@entry=1) at > >> ../../lib/global.c:387 > >> #4 0xb6a25950 in lib_init () at ../../lib/global.c:511 > >> #5 0xb7f35f5c in call_init (l=, argc=argc@entry=6, > >> argv=argv@entry=0xbfe33e64, env=0xbfe33e80) at dl-init.c:72 > >> #6 0xb7f36062 in call_init (env=0xbfe33e80, argv=0xbfe33e64, argc=6, > >> l=) at dl-init.c:30 > >> #7 _dl_init (main_map=, argc=6, argv=0xbfe33e64, > >> env=0xbfe33e80) at dl-init.c:119 > >> #8 0xb7f270fa in _dl_start_user () from /lib/ld-linux.so.2 > >> (gdb) frame 1 > >> #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb > >> "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 > >> 455 return __xstat (_STAT_VER, __path, __statbuf); > >> > >> Why did it end up with EIP=0 I don't know. > >> > >> It seems there's some incompatibility between installwatch's LD_PRELOAD > >> and glibc. > >> > >> Could you have a look at it? > >> > >> Regards > >> Jiri Palecek > > Jiri, > > > > Thanks for the report. In order to help me narrow this down are you able to > > provide a simple test case to reproduce the problem? > > I don't know if it's simple, but here goes. In an empty directory: > > $ touch CMakeLists.txt > > $ cmake . > > $ installwatch cmake . > > > The last line crashes on my system. > > Regards > > Jiri Palecek
Bug#964458: checkinstall: causes segfault of cmake
Hello, On 07. 07. 20 17:11, Stephen Gelman wrote: On Jul 7, 2020, at 9:42 AM, Jiri Palecek wrote: Package: checkinstall Version: 1.6.2+git20170426.d24a630-2 Severity: important File: /usr/bin/installwatch Dear Maintainer, while trying to use checkinstall to create a debianized package from a cmake based source, the build failed with a segfault. These are linked to installwatch and don't happen without it: $ installwatch make cmake_check_build_system INFO : Using a default root directory : /tmp/tmp.JBpq66zd4H make: *** [Makefile:10806: cmake_check_build_system] Neoprávněný přístup do paměti (SIGSEGV) (obraz paměti uložen) There is a backtrace of the crash, which indicates it happens early in the initialization of cmake around a stat call: (gdb) bt #0 0x in ?? () #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 #2 _gnutls_update_system_priorities () at ../../lib/priority.c:1309 #3 0xb6a534f5 in _gnutls_global_init (constructor=constructor@entry=1) at ../../lib/global.c:387 #4 0xb6a25950 in lib_init () at ../../lib/global.c:511 #5 0xb7f35f5c in call_init (l=, argc=argc@entry=6, argv=argv@entry=0xbfe33e64, env=0xbfe33e80) at dl-init.c:72 #6 0xb7f36062 in call_init (env=0xbfe33e80, argv=0xbfe33e64, argc=6, l=) at dl-init.c:30 #7 _dl_init (main_map=, argc=6, argv=0xbfe33e64, env=0xbfe33e80) at dl-init.c:119 #8 0xb7f270fa in _dl_start_user () from /lib/ld-linux.so.2 (gdb) frame 1 #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 455 return __xstat (_STAT_VER, __path, __statbuf); Why did it end up with EIP=0 I don't know. It seems there's some incompatibility between installwatch's LD_PRELOAD and glibc. Could you have a look at it? Regards Jiri Palecek Jiri, Thanks for the report. In order to help me narrow this down are you able to provide a simple test case to reproduce the problem? I don't know if it's simple, but here goes. In an empty directory: $ touch CMakeLists.txt $ cmake . $ installwatch cmake . The last line crashes on my system. Regards Jiri Palecek
Bug#964458: checkinstall: causes segfault of cmake
On Jul 7, 2020, at 9:42 AM, Jiri Palecek wrote: > > Package: checkinstall > Version: 1.6.2+git20170426.d24a630-2 > Severity: important > File: /usr/bin/installwatch > > Dear Maintainer, > > while trying to use checkinstall to create a debianized package from a > cmake based source, the build failed with a segfault. These are linked > to installwatch and don't happen without it: > > $ installwatch make cmake_check_build_system > > INFO : Using a default root directory : /tmp/tmp.JBpq66zd4H > > make: *** [Makefile:10806: cmake_check_build_system] Neoprávněný přístup do > paměti (SIGSEGV) (obraz paměti uložen) > > There is a backtrace of the crash, which indicates it happens early in > the initialization of cmake around a stat call: > > (gdb) bt > #0 0x in ?? () > #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb > "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 > #2 _gnutls_update_system_priorities () at ../../lib/priority.c:1309 > #3 0xb6a534f5 in _gnutls_global_init (constructor=constructor@entry=1) at > ../../lib/global.c:387 > #4 0xb6a25950 in lib_init () at ../../lib/global.c:511 > #5 0xb7f35f5c in call_init (l=, argc=argc@entry=6, > argv=argv@entry=0xbfe33e64, env=0xbfe33e80) at dl-init.c:72 > #6 0xb7f36062 in call_init (env=0xbfe33e80, argv=0xbfe33e64, argc=6, > l=) at dl-init.c:30 > #7 _dl_init (main_map=, argc=6, argv=0xbfe33e64, > env=0xbfe33e80) at dl-init.c:119 > #8 0xb7f270fa in _dl_start_user () from /lib/ld-linux.so.2 > (gdb) frame 1 > #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb > "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 > 455 return __xstat (_STAT_VER, __path, __statbuf); > > Why did it end up with EIP=0 I don't know. > > It seems there's some incompatibility between installwatch's LD_PRELOAD > and glibc. > > Could you have a look at it? > > Regards >Jiri Palecek Jiri, Thanks for the report. In order to help me narrow this down are you able to provide a simple test case to reproduce the problem? Thanks! Stephen
Bug#964458: checkinstall: causes segfault of cmake
Package: checkinstall Version: 1.6.2+git20170426.d24a630-2 Severity: important File: /usr/bin/installwatch Dear Maintainer, while trying to use checkinstall to create a debianized package from a cmake based source, the build failed with a segfault. These are linked to installwatch and don't happen without it: $ installwatch make cmake_check_build_system INFO : Using a default root directory : /tmp/tmp.JBpq66zd4H make: *** [Makefile:10806: cmake_check_build_system] Neoprávněný přístup do paměti (SIGSEGV) (obraz paměti uložen) There is a backtrace of the crash, which indicates it happens early in the initialization of cmake around a stat call: (gdb) bt #0 0x in ?? () #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 #2 _gnutls_update_system_priorities () at ../../lib/priority.c:1309 #3 0xb6a534f5 in _gnutls_global_init (constructor=constructor@entry=1) at ../../lib/global.c:387 #4 0xb6a25950 in lib_init () at ../../lib/global.c:511 #5 0xb7f35f5c in call_init (l=, argc=argc@entry=6, argv=argv@entry=0xbfe33e64, env=0xbfe33e80) at dl-init.c:72 #6 0xb7f36062 in call_init (env=0xbfe33e80, argv=0xbfe33e64, argc=6, l=) at dl-init.c:30 #7 _dl_init (main_map=, argc=6, argv=0xbfe33e64, env=0xbfe33e80) at dl-init.c:119 #8 0xb7f270fa in _dl_start_user () from /lib/ld-linux.so.2 (gdb) frame 1 #1 0xb6a3fbd3 in stat64 (__statbuf=, __path=0xb6b472bb "/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455 455 return __xstat (_STAT_VER, __path, __statbuf); Why did it end up with EIP=0 I don't know. It seems there's some incompatibility between installwatch's LD_PRELOAD and glibc. Could you have a look at it? Regards Jiri Palecek -- System Information: Debian Release: bullseye/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'unstable'), (1, 'experimental-debug'), (1, 'experimental') Architecture: i386 (i686) Foreign Architectures: amd64 Kernel: Linux 5.7.0-1-686-pae (SMP w/2 CPU cores) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=cs_CZ, LC_CTYPE=cs_CZ (charmap=ISO-8859-2), LANGUAGE=cs_CZ (charmap=ISO-8859-2) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages checkinstall depends on: ii dpkg-dev1.20.1~2.gbp7298ec ii file1:5.38-5 ii libc6 2.30-7 ii sensible-utils 0.0.12+nmu1 Versions of packages checkinstall recommends: ii make 4.3-4 Versions of packages checkinstall suggests: ii gettext 0.19.8.1-9 -- no debconf information