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=<optimized out>, pathname=<optimized out>, 
info=<optimized out>) at installwatch.c:3731
  3731                    result=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 <bernha...@mailbox.org>
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 <bernha...@mailbox.org>
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 00000000 sp bfd2951c 
error 14 in cmake[4bf000+10000]
[Sa Aug 15 01:32:54 2020] Code: Bad RIP value.


root@debian:~# coredumpctl list
TIME                            PID   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  0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 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=<optimized out>, 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=<optimized out>) at dl-init.c:30
#6  _dl_init (main_map=<optimized out>, 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  0x00000000 in ?? ()
#1  0xb6a59c13 in stat64 (__statbuf=<optimized out>, __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:387
#4  0xb6a3f990 in lib_init () at ../../lib/global.c:511
#5  0xb7f3be9c in call_init (l=<optimized out>, argc=argc@entry=2, 
argv=argv@entry=0xbfd29694, env=0xbfd296a0) at dl-init.c:72
#6  0xb7f3bfa2 in call_init (env=0xbfd296a0, argv=0xbfd29694, argc=2, 
l=<optimized out>) at dl-init.c:30
#7  _dl_init (main_map=<optimized out>, argc=2, argv=0xbfd29694, 
env=0xbfd296a0) at dl-init.c:119
#8  0xb7f2c0fa in _dl_start_user () from /lib/ld-linux.so.2
(gdb) up
#1  0xb6a59c13 in stat64 (__statbuf=<optimized out>, __path=0xb6b572bb 
"/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455
warning: Source file is more recent than executable.
455       return __xstat (_STAT_VER, __path, __statbuf);
(gdb) print __path
$1 = 0xb6b572bb "/etc/gnutls/config"
(gdb) print __statbuf
$2 = <optimized out>
(gdb) list
450     /* Inlined versions of the real stat and mknod functions.  */
451
452     __extern_inline int
453     __NTH (stat (const char *__path, struct stat *__statbuf))
454     {
455       return __xstat (_STAT_VER, __path, __statbuf);
456     }
457
458     # if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
459     __extern_inline int
(gdb) directory 
/home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes
Source directories searched: 
/home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes:$cdir:$cwd
(gdb) up
#2  _gnutls_update_system_priorities () at ../../lib/priority.c:1309
1309            if (stat(system_priority_file, &sb) < 0) {
(gdb) print system_priority_file
$3 = 0xb6b572bb "/etc/gnutls/config"
(gdb) print sb
$4 = {st_dev = 13168605165528539074, __pad1 = 0, __st_ino = 2097734, st_mode = 
582, st_nlink = 24, st_uid = 3066054816, st_gid = 3066055172, st_rdev = 
13165550790959361556, __pad2 = 47744, st_size = 8461812105492824067, st_blksize 
= 1818588270, st_blocks = 155850206825, st_atim = {tv_sec = 38, tv_nsec = 
-1228906636}, st_mtim = {tv_sec = 1, tv_nsec = 0}, st_ctim = {tv_sec = 
-1228906636, tv_nsec = 1}, st_ino = 13168650293979643904}




############



benutzer@debian:~/test$ /home/benutzer/source/rr/git/obj/bin/rr installwatch 
cmake .
rr: Saving execution to trace directory 
`/home/benutzer/.local/share/rr/installwatch-1'.

INFO : Using a default root directory : /tmp/tmp.mzZzOVWo9S

/usr/bin/installwatch: Zeile 338:  8117 Speicherzugriffsfehler  (Speicherabzug 
geschrieben) "$@"




benutzer@debian:~/test$ /home/benutzer/source/rr/git/obj/bin/rr ps 
/home/benutzer/.local/share/rr/installwatch-1
PID     PPID    EXIT    CMD
8102    --      1       installwatch cmake .
8103    8102    0       uname -m
8104    8102    0       basename /usr/bin/installwatch
8105    8102    0       getopt -a -n installwatch -o +r:e:o:d:v:tb -l 
root:,transl:,backup:,exclude:,logfile:,dbgfile:,dbglvl:,help,version,copyright 
-- cmake .
8106    8102    0       mktemp -q -d -p /tmp
8107    8102    0       (forked without exec)
8108    8107    0       (forked without exec)
8109    8107    0       sort -u
8110    8107    0       (forked without exec)
8111    8102    0       (forked without exec)
8112    8102    1       grep -qv ^/
8113    8102    0       cat /dev/null
8114    8102    0       (forked without exec)
8115    8102    1       grep -qv ^/
8116    8102    0       cat /dev/null
8117    8102    -11     cmake .





/home/benutzer/source/rr/git/obj/bin/rr replay 
/home/benutzer/.local/share/rr/installwatch-1 -p 8117

directory /home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes
directory 
/home/benutzer/source/checkinstall/try1/checkinstall-1.6.2+git20170426.d24a630/installwatch
set width 0
set pagination off
display/i $pc
cont
reverse-stepi
reverse-stepi


benutzer@debian:~/test$ /home/benutzer/source/rr/git/obj/bin/rr replay 
/home/benutzer/.local/share/rr/installwatch-1 -p 8117

INFO : Using a default root directory : /tmp/tmp.mzZzOVWo9S

GNU gdb (Debian 9.2-1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/cmake...
(No debugging symbols found in /usr/bin/cmake)
Really redefine built-in command "restart"? (y or n) [answered Y; input not 
from terminal]
Remote debugging using 127.0.0.1:8170

--------------------------------------------------
 ---> Reached target process 8117 at event 3409.
--------------------------------------------------
Reading symbols from /lib/ld-linux.so.2...
Reading symbols from 
/usr/lib/debug/.build-id/c3/506778ae80f9d00e53b31eb690f8c0febb1d4a.debug...
0xb7ef20b0 in _start () from /lib/ld-linux.so.2
(rr) directory 
/home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes
Source directories searched: 
/home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes:$cdir:$cwd
(rr) directory 
/home/benutzer/source/checkinstall/try1/checkinstall-1.6.2+git20170426.d24a630/installwatch
Source directories searched: 
/home/benutzer/source/checkinstall/try1/checkinstall-1.6.2+git20170426.d24a630/installwatch:/home/benutzer/source/libgnutls30/orig/gnutls28-3.6.14/lib/includes:$cdir:$cwd
(rr) set width 0
(rr) set pagination off
(rr) display/i $pc
1: x/i $pc
=> 0xb7ef20b0 <_start>: mov    %esp,%eax
(rr) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
1: x/i $pc
=> 0x0: <error: Cannot access memory at address 0x0>
(rr) reverse-stepi

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
1: x/i $pc
=> 0x0: <error: Cannot access memory at address 0x0>
(rr) reverse-stepi
0xb7edd1d8 in __xstat64 (version=<optimized out>, pathname=<optimized out>, 
info=<optimized out>) at installwatch.c:3731
warning: Source file is more recent than executable.
3731                    result=true_xstat64(version,pathname,info);
1: x/i $pc
=> 0xb7edd1d8 <__xstat64+88>:   jmp    *%eax
(rr) bt
#0  0xb7edd1d8 in __xstat64 (version=<optimized out>, pathname=<optimized out>, 
info=<optimized out>) at installwatch.c:3731
#1  0xb6a0fc13 in stat64 (__statbuf=<optimized out>, __path=0xb6b0d2bb 
"/etc/gnutls/config") at /usr/include/i386-linux-gnu/sys/stat.h:455
#2  _gnutls_update_system_priorities () at ../../lib/priority.c:1309
#3  0xb6a23535 in _gnutls_global_init (constructor=constructor@entry=1) at 
../../lib/global.c:387
#4  0xb69f5990 in lib_init () at ../../lib/global.c:511
#5  0xb7f01e9c in call_init (l=<optimized out>, argc=argc@entry=2, 
argv=argv@entry=0xbffa61e4, env=0xbffa61f0) at dl-init.c:72
#6  0xb7f01fa2 in call_init (env=0xbffa61f0, argv=0xbffa61e4, argc=2, 
l=<optimized out>) at dl-init.c:30
#7  _dl_init (main_map=<optimized out>, argc=2, argv=0xbffa61e4, 
env=0xbffa61f0) at dl-init.c:119
#8  0xb7ef20fa in _dl_start_user () from /lib/ld-linux.so.2

(rr) print true_xstat64
$1 = (int (*)(int, const char *, struct stat64 *)) 0x0
(rr) print &true_xstat64
$2 = (int (**)(int, const char *, struct stat64 *)) 0xb7eec064 <true_xstat64>




Reply via email to