Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED?] lshw - free(): invalid pointer Aborted
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Mon Jul 01, 2019 4:02 pm    Post subject: [SOLVED?] lshw - free(): invalid pointer Aborted Reply with quote

Hi,

Trying to figure out why /usr/sbin/lshw won't run (I think it used to at some point, and know it worked from the minimal-iso when installing)...
(not that I really need it anymore - but worried if there's other stuff not running properly...)

Code:
tor ~ # lshw
free(): invalid pointer
Aborted
tor ~ # lddtree /usr/sbin/lshw
lshw => /usr/sbin/lshw (interpreter => /lib64/ld-linux-x86-64.so.2)
    libresolv.so.2 => /lib64/libresolv.so.2
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/libstdc++.so.6
        libm.so.6 => /lib64/libm.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/libgcc_s.so.1
    libc.so.6 => /lib64/libc.so.6
tor ~ # file /usr/sbin/lshw
/usr/sbin/lshw: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, stripped


And strace-output: http://dpaste.com/2BR327F

emerge --info
Code:
tor ~ # emerge --info
Portage 2.3.66 (python 3.6.5-final-0, default/linux/amd64/17.1/no-multilib/hardened, gcc-9.1.0, glibc-2.29-r2, 4.19.52-gentoo x86_64)
=================================================================
System uname: Linux-4.19.52-gentoo-x86_64-AMD_GX-412TC_SOC-with-gentoo-2.6
KiB Mem:     4021680 total,   1262532 free
KiB Swap:    6291636 total,   6291636 free
Timestamp of repository gentoo: Sun, 30 Jun 2019 23:30:01 +0000
Head commit of repository gentoo: 9173c1ed63aa9f7570a1d7b715046bd6f88893c4
sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.31.1 p7) 2.31.1
app-shells/bash:          4.4_p23-r1::gentoo
dev-lang/perl:            5.28.2-r1::gentoo
dev-lang/python:          2.7.15::gentoo, 3.6.5::gentoo
dev-util/cmake:           3.14.3::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.41.2::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.31.1-r6::gentoo
sys-devel/gcc:            9.1.0-r1::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.19::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r2::gentoo
Repositories:

gentoo
    location: /opt/portage
    sync-type: rsync
    sync-uri: rsync://rsync.vlh.dk/gentoo-portage
    priority: -1
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts:

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt /var/spool/munin-async/.ssh"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize -fno-delete-null-pointer-checks -flifetime-dse=1"
DISTDIR="/opt/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="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize"
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 sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize"
GENTOO_MIRRORS="http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://trumpetti.atm.tut.fi/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize -fno-delete-null-pointer-checks -flifetime-dse=1"
MAKEOPTS="-j4"
PKGDIR="/opt/packages"
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="acl amd64 berkdb bzip2 caps crypt cxx gd geoip gnutls graphite hardened iconv idn ipv6 libtirpc lto ncurses nls nptl openmp pam pcre pgo pie readline rsync-verify seccomp ssl ssp syslog udev unicode usb xattr xml xtpax zlib" ABI_X86="64" 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" CPU_FLAGS_X86="aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="garmin" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24" 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


I *suspect* LTO? but
Code:
tor ~ # cat /etc/portage/package.env
# No LTO
# System
dev-libs/elfutils no-lto.conf

# World
=mail-mta/nullmailer-2.0-r1 no-lto.conf
dev-libs/libbsd no-lto.conf
sys-apps/lshw no-lto.conf

## No Graphite
# System

# World

## No tmpfs
dev-db/mariadb notmpfs.conf
sys-devel/gcc notmpfs.conf
Doesn't really change things (haven't compared strace-output with LTO/noLTO)

Anyone know where to start, how to proceed?


Last edited by freke on Sat Jul 06, 2019 3:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Mon Jul 01, 2019 6:42 pm    Post subject: Reply with quote

It could be...
  1. a bug in lshw, most probably in src/core/pci.cc
  2. a problem in the way you compiled the program (either 'lto' as you suggest, or 'hardened')
  3. a configuration detail on your machine (one of the tmpfs mounts is too small, etc.)
It would be nice to find the line in the source code where the error happens. You could
  1. emerge lshw with debug symbols, run lshw in gdb and create a backtrace after the error happens
  2. add debug statements to the source code and try to find exactly the line in the source code. It guess you will find the error in function "load_pcidb()" in src/core/pci.cc or in one of the functions it calls.
  3. use some other tracing technique
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Wed Jul 03, 2019 2:45 pm    Post subject: Reply with quote

Thanks, I'll try to dig deeper and read up on debug symbols/gdb.

I tried with
Code:
CFLAGS="${CFLAGS} -fno-stack-protector -no-pie"
CXXFLAGS="${CXXFLAGS} -fno-stack-protector -no-pie"
LDFLAGS="${LDFLAGS} -no-pie"
for lshw (that's *basically* what hardened does? but is it enough to turn off for lshw only?
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Wed Jul 03, 2019 3:28 pm    Post subject: Reply with quote

Please take a look at: https://wiki.gentoo.org/wiki/Debugging
  1. create /etc/portage/env/debugsyms and /etc/portage/env/installsources
  2. add 'sys-apps/lshw debugsyms installsources' to /etc/portage/package.env
  3. re-emerge lshw
  4. run lshw in gdb
  5. after the SIGABRT: enter "bt" to create a backtrace
  6. post the backtrace
That's how I would start.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21861

PostPosted: Thu Jul 04, 2019 12:30 am    Post subject: Reply with quote

Neither stack-protector nor pie need to be disabled for debugging. If disabling them fixes the program, then there is something else wrong that should be found and fixed.

mike155's advice is good, but I want to clarify one point. In step 1, don't create them as empty files. Create them as described in the link he provides.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 1:43 pm    Post subject: Reply with quote

This
mike155 wrote:
Please take a look at: https://wiki.gentoo.org/wiki/Debugging
  1. create /etc/portage/env/debugsyms and /etc/portage/env/installsources
  2. add 'sys-apps/lshw debugsyms installsources' to /etc/portage/package.env
  3. re-emerge lshw
  4. run lshw in gdb
  5. after the SIGABRT: enter "bt" to create a backtrace
  6. post the backtrace
That's how I would start.
led to this
Code:
tor ~ # gdb /usr/sbin/lshw
GNU gdb (Gentoo 8.3 vanilla) 8.3
Copyright (C) 2019 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
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/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) run
Starting program: /usr/sbin/lshw
free(): invalid pointer

Program received signal SIGABRT, Aborted.
0x00007ffff7e2c551 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7e2c551 in raise () from /lib64/libc.so.6
#1  0x00007ffff7e15539 in abort () from /lib64/libc.so.6
#2  0x00007ffff7e72e18 in ?? () from /lib64/libc.so.6
#3  0x00007ffff7e7acea in ?? () from /lib64/libc.so.6
#4  0x00007ffff7e7c674 in ?? () from /lib64/libc.so.6
#5  0x00005555555a7e58 in load_pcidb() [clone .lto_priv.0] ()
#6  0x00005555555a3c4a in scan_pci(hwNode&) ()
#7  0x00005555555c8c55 in scan_system(hwNode&) ()
#8  0x00005555555769b4 in main ()
(gdb) quit
A debugging session is active.

        Inferior 1 [process 6971] will be killed.

Quit anyway? (y or n) y


That means something is wrong in /lib64/libc.so.6 ?
Meaning my glibc is not well?
Back to top
View user's profile Send private message
gentoo_ram
Guru
Guru


Joined: 25 Oct 2007
Posts: 480
Location: San Diego, California USA

PostPosted: Thu Jul 04, 2019 2:56 pm    Post subject: Reply with quote

The stuff in libc just says that some code crashed while calling into the C library. In my experience, that doesn't mean there's a problem with the C library, it means there's a problem with the program's code when calling into the C library.

The last function in lshw is load_pcidb(). Just looked at the source. That function is trying to load a pci.ids file so it can eventually translate PCI ID values to strings. The places it is looking for the file is:

{PREFIX}/share/lshw/pci.ids
/usr/local/share/pci.ids
/usr/share/pci.ids
/etc/pci.ids
/usr/share/hwdata/pci.ids
/usr/share/misc/pci.ids

Do any of those files exist or maybe are corrupted in some way?

Of course, there could have been an issue earlier in the program that messed up memory and the program didn't crash until it got to that point. Maybe it had problems scanning hardware before it got to that point?

I also see something in the thread about a stack protector setting. The variables in that function are stack variables and could become large. Is the program being compiled with something that would limit the stack size? That might cause it problems.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 3:12 pm    Post subject: Reply with quote

I already suspected/had a little look at pci.ids as my strace-output stopped in the middle of that file.

I *had* a /usr/share/misc/pci.ids.gz which I gunzip'ed - so now it's *just* /usr/share/misc/pci.ids


Re-emerged sys-apps/hwids-20180917 - no change
Deleted distfile + re-emerged sys-apps/hwids-20180917 - no change

Code:
tor ~ # ls -l /usr/share/misc/
total 13744
-rw-r--r-- 1 root root 2453239 Sep 17  2018 iab.txt
drwxr-xr-x 2 root root   12288 Mar 23 02:43 magic
-rw-r--r-- 1 root root 5408368 Mar 23 02:42 magic.mgc
-rw-r--r-- 1 root root 3981760 Sep 17  2018 oui.txt
-rw-r--r-- 1 root root 1134006 Sep 17  2018 pci.ids
-rw-r--r-- 1 root root  266916 Jul  4 17:03 pci.ids.gz
-rw-r--r-- 1 root root  597855 Sep 17  2018 usb.ids
-rw-r--r-- 1 root root  207307 Jul  4 17:03 usb.ids.gz



My strace-output shows
Code:
read(3, "ller\n\t01  Token ring network con"..., 1024) = 1024
read(3, "us towards host CPU\n\t0a  InfiniB"..., 1024) = 1024
read(3, "ric\n\t\t10  Extended\n\t80  Input de"..., 1024) = 1024
read(3, "ion controller\n\t00  Network and "..., 1024) = 438
read(3, "", 1024)                       = 0
brk(0x55c06f174000)                     = 0x55c06f174000
brk(0x55c06f198000)                     = 0x55c06f198000
brk(0x55c06f1e1000)                     = 0x55c06f1e1000
brk(0x55c06f26d000)                     = 0x55c06f26d000
brk(0x55c06f38d000)                     = 0x55c06f38d000
brk(0x55c06f3ae000)                     = 0x55c06f3ae000
close(3)                                = 0
munmap(0x7f6a5c6a3000, 2101248)         = 0
writev(2, [{iov_base="free(): invalid pointer", iov_len=23}, {iov_base="\n", iov_len=1}], 2) = 24
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6a5d758000
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 17164
gettid()                                = 17164
tgkill(17164, 17164, SIGABRT)           = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=17164, si_uid=0} ---
+++ killed by SIGABRT +++

Only occurrence of 'Network and' is just before the end of pci.ids
Code:
cat /usr/share/misc/pci.ids
...
C 10  Encryption controller
        00  Network and computing encryption device
        10  Entertainment encryption device
        80  Encryption controller
C 11  Signal processing controller
        00  DPIO module
        01  Performance counters
        10  Communication synchronizer
        20  Signal processing management
        80  Signal processing controller
C 12  Processing accelerators
        00  Processing accelerators
C 13  Non-Essential Instrumentation
C 40  Coprocessor
C ff  Unassigned class


[EDIT]
Tried both sys-apps/hwids-20171003 and sys-apps/hwids-20190316 with same result
[/EDIT]
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Jul 04, 2019 3:54 pm    Post subject: Reply with quote

After your first post, I analyzed your strace file and I guessed the error happens in load_pcidb(), more specifically in a constructor or destructor of a vector object. See my first post in this thread.

Your backtrace confirms that. :-)

I think that the error happens in lshw, not in glibc (see line #5 of the backtrace). The glibc calls you see (#4 -#0) happen after the error - they are used to output of the error message and to abort. If you like, you can add "sys-libs/glibc debugsyms installsources' to /etc/portage/package.env, re-emerge glibc and re-run the gdb test. The backtrace will tell you which glibc functions were called. That's a general recommendation: whenever you see "??" in a backtrace, add the corresponding package to /etc/portage/package.env, re-emerge the package and re-run the test: the question marks will be replaced by meaningful debug symbols.

The error is not related to configuration files or to the PCI or hwid databases.

I'm surprised that the backtrace doesn't show the exact line in which the error happened. Maybe that's because it happened in a constructor/destructor.

Please give me a couple of hours to think about the next step. I will write more later in the evening.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 4:58 pm    Post subject: Reply with quote

Thanks a lot :D

Last edited by freke on Thu Jul 04, 2019 5:38 pm; edited 2 times in total
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Jul 04, 2019 5:26 pm    Post subject: Reply with quote

Let's see...

Below is a snippet from the original source code (file: src/core/pci.cc)
Code:
fstatic bool load_pcidb()
{
  vector < string > lines;
  vector < string > filenames;

  splitlines(PCIID_PATH, filenames, ':');
  for (int i = filenames.size() - 1; i >= 0; i--)
  {
    lines.clear();
    if (loadfile(filenames[i], lines))
      parse_pcidb(lines);
  }

  return (pci_devices.size() > 0);
}

I added some DEBUG statements:
Code:
static bool load_pcidb()
{
  vector < string > lines;
  vector < string > filenames;

  splitlines(PCIID_PATH, filenames, ':');
  for (int i = filenames.size() - 1; i >= 0; i--)
  {
    lines.clear();
    printf( "\nDEBUG 0: %s\n", filenames[i].c_str() );
    if (loadfile(filenames[i], lines)) {
      printf( "\nDEBUG 1\n" );
      parse_pcidb(lines);
      printf( "\nDEBUG 2\n" );
    }
    printf( "\nDEBUG 3\n" );
  }
  printf( "\nDEBUG 4\n" );

  return (pci_devices.size() > 0);
}

I compiled and straced the program:
Code:
write(1, "\n", 1)                       = 1
write(1, "DEBUG 0: /usr/share/misc/pci.ids"..., 33) = 33
openat(AT_FDCWD, "/usr/share/misc/pci.ids", O_RDONLY) = 3
read(3, "#\n#\tList of PCI ID's\n#\n#\tVersion"..., 1024) = 1024
read(3, "play Controller)\n\t7a07  HDA (Hig"..., 1024) = 1024
..... (many lines)
read(3, "ion controller\n\t00  Network and "..., 1024) = 438
read(3, "", 1024)                       = 0
brk(0x563a47ce7000)                     = 0x563a47ce7000
brk(0x563a47d0c000)                     = 0x563a47d0c000
brk(0x563a47d54000)                     = 0x563a47d54000
brk(0x563a47de0000)                     = 0x563a47de0000
brk(0x563a47f00000)                     = 0x563a47f00000
brk(0x563a47f21000)                     = 0x563a47f21000
close(3)                                = 0
munmap(0x7f40ef713000, 2101248)         = 0
write(1, "\n", 1)                       = 1
write(1, "DEBUG 1\n", 8)                = 8
#
# <----------------- The error occurs here, according to your strace file
#
brk(0x563a47f42000)                     = 0x563a47f42000
brk(0x563a47f80000)                     = 0x563a47f80000
brk(0x563a47fc0000)                     = 0x563a47fc0000
brk(0x563a48040000)                     = 0x563a48040000
brk(0x563a48140000)                     = 0x563a48140000
brk(0x563a48341000)                     = 0x563a48341000
write(1, "\n", 1)                       = 1
write(1, "DEBUG 2\n", 8)                = 8
write(1, "\n", 1)                       = 1
write(1, "DEBUG 3\n", 8)                = 8
write(1, "\n", 1)                       = 1
write(1, "DEBUG 4\n", 8)                = 8
getcwd("/var/tmp/portage/sys-apps/lshw-02.18b/work/lshw-B.02.18/src", 4097) = 60
chdir("/sys/bus/pci/devices")           = 0
openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
getdents64(3, /* 26 entries */, 32768)  = 816
lstat("0000:00:1f.2", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
lstat("0000:00:1c.0", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
lstat("0000:09:00.0", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
lstat("0000:00:1f.0", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0

It seems that the error occurs in or near the call to function parse_pcidb(lines). It can't be inside of function parse_pcidb(lines), because the backtrace doesn't show this function.

... to be continued later this evening
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 5:39 pm    Post subject: Reply with quote

I get this after adding glibc to my 'debugging environment':
Code:
gdb /usr/sbin/lshw
GNU gdb (Gentoo 8.3 vanilla) 8.3
Copyright (C) 2019 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
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/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) run
Starting program: /usr/sbin/lshw
free(): invalid pointer

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50        return ret;
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7e15539 in __GI_abort () at abort.c:79
#2  0x00007ffff7e72e18 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7f8aac8 "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff7e7acea in malloc_printerr (str=str@entry=0x7ffff7f88c22 "free(): invalid pointer") at malloc.c:5352
#4  0x00007ffff7e7c674 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=<optimized out>) at malloc.c:4181
#5  0x00005555555a7e58 in load_pcidb() [clone .lto_priv.0] ()
#6  0x00005555555a3c4a in scan_pci(hwNode&) ()
#7  0x00005555555c8c55 in scan_system(hwNode&) ()
#8  0x00005555555769b4 in main ()
(gdb)
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Jul 04, 2019 6:10 pm    Post subject: Reply with quote

Your backtrace looks better now. :-)

Let's try to find the bug:
  1. Open lshw with gdb:
    Code:
    gdb /usr/sbin/lshw

  2. Set a breakpoint at the start of function load_pcidb()
    Code:
    break load_pcidb

  3. Run the program until it reaches the function:
    Code:
    run

  4. Advance to line "parse_pcidb(lines)". Enter
    Code:
    next
    until you are at the line "parse_pcidb(lines)"

  5. Run another "step". The program will probably crash, right?

  6. Quit gdb and repeat steps 1-4

  7. When you are at the line "parse_pcidb(lines)", use
    Code:
    step
    instead of "next". "step" will enter the function.

  8. Run "step" until you see something strange. I can't predict what you will see, but I'm sure that you will recognize the error when it occurs

  9. Please post the output

Below is the output on my machine:
Code:
Reading symbols from /usr/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) break load_pcidb
Breakpoint 1 at 0x16d2c: load_pcidb. (2 locations)
(gdb) run
Starting program: /usr/sbin/lshw
PCI (sysfs) 
Breakpoint 1, load_pcidb () at pci.cc:511
511     {
(gdb) next
515       splitlines(PCIID_PATH, filenames, ':');
(gdb) next
513       vector < string > filenames;
(gdb) next
515       splitlines(PCIID_PATH, filenames, ':');
(gdb) next
516       for (int i = filenames.size() - 1; i >= 0; i--)
(gdb) next
518         lines.clear();
(gdb) next
519         if (loadfile(filenames[i], lines))
(gdb) next
520           parse_pcidb(lines);
(gdb) step
parse_pcidb (list=...) at pci.cc:520
520           parse_pcidb(lines);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=...,
    __s=0x5555555e849e "", this=0x7fffffffd820) at pci.cc:520
520           parse_pcidb(lines);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    __end=<optimized out>, __beg=<optimized out>, this=<optimized out>) at pci.cc:520
520           parse_pcidb(lines);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (
    __end=<optimized out>, __beg=<optimized out>, this=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/ext/new_allocator.h:81
81            new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=...,
    __s=0x5555555e849e "", this=0x7fffffffd820)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:516
516           { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    __end=0x5555555e849e "", __beg=0x5555555e849e "", this=0x7fffffffd820)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:516
516           { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (
    __end=0x5555555e849e "", __beg=0x5555555e849e "", this=0x7fffffffd820)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:252
252             _M_construct(_InIterator __beg, _InIterator __end)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    this=0x7fffffffd820, __beg=0x5555555e849e "", __end=0x5555555e849e "")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:206
206           basic_string<_CharT, _Traits, _Alloc>::
(gdb) step
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::distance<char const*> (__last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:215
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::__distance<char const*> (__last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/stl_iterator_base_funcs.h:138
138         distance(_InputIterator __first, _InputIterator __last)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    this=0x7fffffffd820, __beg=0x5555555e849e "", __end=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (
    __k2=<optimized out>, __k1=0x5555555e849e "", __p=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0,
    __s=0x5555555e849e "", __d=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:385
385           _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    this=0x7fffffffd820, __beg=0x5555555e849e "", __end=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (
    __k2=<optimized out>, __k1=0x5555555e849e "", __p=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0,
    __s=0x5555555e849e "", __d=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0,
    __s=0x5555555e849e "", __d=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::char_traits<char>::copy (__n=0, __s2=0x5555555e849e "", __s1=0x7fffffffd830 "@\330\377\377\377\177")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/char_traits.h:350
350             if (__n == 0)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (
    this=0x7fffffffd820, __beg=0x5555555e849e "", __end=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=0,
    this=0x7fffffffd820) at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length (this=0x7fffffffd820,
    __length=0) at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:203
203           _M_set_length(size_type __n)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=0,
    this=0x7fffffffd820) at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/basic_string.h:206
206             traits_type::assign(_M_data()[__n], _CharT());
(gdb) step
std::char_traits<char>::assign (__c2=<optimized out>, __c1=@0x7fffffffd830: 64 '@')
    at /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/include/g++-v8/bits/char_traits.h:287
287           { __c1 = __c2; }
(gdb) step
parse_pcidb (list=...) at pci.cc:396
396       memset(u, 0, sizeof(u));
(gdb)

A lot of C++ Voodoo happens before the first line of parse_pcidb() is executed. I guess that one of those steps fails on your machine.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 6:40 pm    Post subject: Reply with quote

Crashed after first 'next'

Code:
tor ~ # gdb /usr/sbin/lshw
GNU gdb (Gentoo 8.3 vanilla) 8.3
Copyright (C) 2019 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
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/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) break load_pcidb
Breakpoint 1 at 0x18df2 (2 locations)
(gdb) run
Starting program: /usr/sbin/lshw
PCI (sysfs)
Breakpoint 1, 0x00005555555a7850 in load_pcidb() [clone .lto_priv.0] ()
(gdb) next
Single stepping until exit from function _ZL10load_pcidbv.lto_priv.0,
which has no line number information.
free(): invalid pointer

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50        return ret;
(gdb)


I tried stepping after first breakpoint:
Code:
tor ~ # gdb /usr/sbin/lshw
GNU gdb (Gentoo 8.3 vanilla) 8.3
Copyright (C) 2019 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
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/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) break load_pcidb
Breakpoint 1 at 0x18df2 (2 locations)
(gdb) run
Starting program: /usr/sbin/lshw
PCI (sysfs)
Breakpoint 1, 0x00005555555a7850 in load_pcidb() [clone .lto_priv.0] ()
(gdb) step
Single stepping until exit from function _ZL10load_pcidbv.lto_priv.0,
which has no line number information.
operator delete (ptr=0x555555616f50) at /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/gcc-9.1.0/libstdc++-v3/libsupc++/del_op.cc:49
49      /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/gcc-9.1.0/libstdc++-v3/libsupc++/del_op.cc: No such file or directory.
(gdb) step
__GI___libc_free (mem=0x555555616f50) at malloc.c:3094
It looks for a file from my PORTAGE_TMPDIR ?

Setpping through load_pcidb()
Code:
Breakpoint 1, 0x00005555555a7850 in load_pcidb() [clone .lto_priv.0] ()
(gdb) step
Single stepping until exit from function _ZL10load_pcidbv.lto_priv.0,
which has no line number information.
operator delete (ptr=0x555555616f50) at /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/gcc-9.1.0/libstdc++-v3/libsupc++/del_op.cc:49
49      /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/gcc-9.1.0/libstdc++-v3/libsupc++/del_op.cc: No such file or directory.
(gdb) step
__GI___libc_free (mem=0x555555616f50) at malloc.c:3094
3094    {
(gdb) step
3099        = atomic_forced_read (__free_hook);
(gdb) step
3100      if (__builtin_expect (hook != NULL, 0))
(gdb) step
3106      if (mem == 0)                              /* free(0) has no effect */
(gdb) step
3109      p = mem2chunk (mem);
(gdb) step
3111      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
(gdb) step
3129      MAYBE_INIT_TCACHE ();
(gdb) step
3131      ar_ptr = arena_for_chunk (p);
(gdb) step
3132      _int_free (ar_ptr, p, 0);
(gdb) step
_int_free (av=0x7ffff7fbfaa0 <main_arena>, p=0x555555616f40, have_lock=0) at malloc.c:4163
4163    {
(gdb) step
4173      size = chunksize (p);
(gdb) step
4179      if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0)
(gdb) step
4184      if (__glibc_unlikely (size < MINSIZE || !aligned_OK (size)))
(gdb) step
4192        if (tcache != NULL && tc_idx < mp_.tcache_bins)
(gdb) step
4195            tcache_entry *e = (tcache_entry *) chunk2mem (p);
(gdb) step
4201            if (__glibc_unlikely (e->key == tcache))
(gdb) step
4214            if (tcache->counts[tc_idx] < mp_.tcache_count)
(gdb) step
4216                tcache_put (p, tc_idx);
(gdb) step
tcache_put (tc_idx=0, chunk=0x555555616f40) at malloc.c:4216
4216                tcache_put (p, tc_idx);
(gdb) step
2935      e->key = tcache;
(gdb) step
2937      e->next = tcache->entries[tc_idx];
(gdb) step
2938      tcache->entries[tc_idx] = e;
(gdb) step
2939      ++(tcache->counts[tc_idx]);
(gdb) step
_int_free (av=0x7ffff7fbfaa0 <main_arena>, p=0x555555616f40, have_lock=<optimized out>) at malloc.c:4217
4217                return;
(gdb) step
0x00005555555a7912 in load_pcidb() [clone .lto_priv.0] ()
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 7:05 pm    Post subject: Reply with quote

Added my no-lto.conf and getting output more similar to yours:
Code:
tor ~ # gdb /usr/sbin/lshw
GNU gdb (Gentoo 8.3 vanilla) 8.3
Copyright (C) 2019 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
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/sbin/lshw...
Reading symbols from /usr/lib/debug//usr/sbin/lshw.debug...
(gdb) break load_pcidb
Breakpoint 1 at 0x152b5: load_pcidb. (2 locations)
(gdb) run
Starting program: /usr/sbin/lshw
PCI (sysfs)
Breakpoint 1, load_pcidb () at pci.cc:511
511     {
(gdb) next
515       splitlines(PCIID_PATH, filenames, ':');
(gdb) next
513       vector < string > filenames;
(gdb) next
515       splitlines(PCIID_PATH, filenames, ':');
(gdb) next
^[[A
515       splitlines(PCIID_PATH, filenames, ':');
(gdb) next
516       for (int i = filenames.size() - 1; i >= 0; i--)
(gdb) next
518         lines.clear();
(gdb) next
519         if (loadfile(filenames[i], lines))
(gdb) next
520           parse_pcidb(lines);
(gdb) next
free(): invalid pointer

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50        return ret;
(gdb)



Stepping from parse_pcidb(lines);
Code:
(gdb) next
520           parse_pcidb(lines);
(gdb) step
parse_pcidb (list=...) at pci.cc:520
520           parse_pcidb(lines);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=..., __s=0x5555555ea49e "", this=0x7fffffffda90)
    at pci.cc:520
520           parse_pcidb(lines);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::_Alloc_hider (this=0x7fffffffda90, __a=...,
    __dat=0x7fffffffdaa0 "e") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/ext/new_allocator.h:83
83            new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__a=..., __s=0x5555555ea49e "", this=0x7fffffffda90)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:527
527           { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (__end=0x5555555ea49e "", __beg=0x5555555ea49e "",
    this=0x7fffffffda90) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:527
527           { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+npos); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct_aux<char const*> (__end=0x5555555ea49e "",
    __beg=0x5555555ea49e "", this=0x7fffffffda90) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:263
263             _M_construct(_InIterator __beg, _InIterator __end)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (this=0x7fffffffda90, __beg=0x5555555ea49e "",
    __end=0x5555555ea49e "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:206
206           basic_string<_CharT, _Traits, _Alloc>::
(gdb) step
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::distance<char const*> (__last=<optimized out>, __first=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:215
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::__distance<char const*> (__last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/stl_iterator_base_funcs.h:138
138         distance(_InputIterator __first, _InputIterator __last)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (this=0x7fffffffda90, __beg=0x5555555ea49e "",
    __end=0x5555555ea49e "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (__k2=0x5555555ea49e "", __k1=0x5555555ea49e "",
    __p=0x7fffffffdaa0 "e") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0, __s=0x5555555ea49e "", __d=0x7fffffffdaa0 "e")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:396
396           _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (this=0x7fffffffda90, __beg=0x5555555ea49e "",
    __end=0x5555555ea49e "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (__k2=0x5555555ea49e "", __k1=0x5555555ea49e "",
    __p=0x7fffffffdaa0 "e") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0, __s=0x5555555ea49e "", __d=0x7fffffffdaa0 "e")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=0, __s=0x5555555ea49e "", __d=0x7fffffffdaa0 "e")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::char_traits<char>::copy (__n=0, __s2=0x5555555ea49e "", __s1=0x7fffffffdaa0 "e")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/char_traits.h:363
363             if (__n == 0)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> (this=0x7fffffffda90, __beg=0x5555555ea49e "",
    __end=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=0, this=0x7fffffffda90)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length (this=0x7fffffffda90, __length=0)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:214
214           _M_set_length(size_type __n)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=0, this=0x7fffffffda90)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:217
217             traits_type::assign(_M_data()[__n], _CharT());
(gdb) step
std::char_traits<char>::assign (__c2=<optimized out>, __c1=@0x7fffffffdaa0: 101 'e')
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/char_traits.h:300
300           { __c1 = __c2; }
(gdb) step
parse_pcidb (list=...) at /usr/include/bits/string_fortified.h:71
71        return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
(gdb) step
915           size() const _GLIBCXX_NOEXCEPT
(gdb) step
400         line = hw::strip(list[i]);
(gdb) step
std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::operator[] (this=0x7fffffffda30, __n=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/stl_vector.h:1040
1040          operator[](size_type __n) _GLIBCXX_NOEXCEPT
(gdb) step
hw::strip (s=...) at hw.cc:50
50      {
(gdb) step
51        string result = s;
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (__str=..., this=0x7fffffffdc50)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/ext/new_allocator.h:83
83            new_allocator(const new_allocator&) _GLIBCXX_USE_NOEXCEPT { }
(gdb) step
hw::strip (s=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:936
936           length() const _GLIBCXX_NOEXCEPT
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=this@entry=0x7fffffffdc50,
    __beg=0x55555576e740 "#", __end=0x55555576e741 "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:206
206           basic_string<_CharT, _Traits, _Alloc>::
(gdb) step
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::distance<char*> (__last=<optimized out>, __first=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:215
215             size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
(gdb) step
std::__distance<char*> (__last=<optimized out>, __first=<optimized out>)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/stl_iterator_base_funcs.h:138
138         distance(_InputIterator __first, _InputIterator __last)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=this@entry=0x7fffffffdc50,
    __beg=0x55555576e740 "#", __end=0x55555576e741 "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars (__k2=0x55555576e741 "", __k1=0x55555576e740 "#",
    __p=0x7fffffffdc60 "\027") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:225
225               { this->_S_copy_chars(_M_data(), __beg, __end); }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy (__n=1, __s=0x55555576e740 "#", __d=0x7fffffffdc60 "\027")
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:392
392           _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
(gdb) step
349               traits_type::assign(*__d, *__s);
(gdb) step
std::char_traits<char>::assign (__c2=@0x55555576e740: 35 '#', __c1=@0x7fffffffdc60: 23 '\027')
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/char_traits.h:300
300           { __c1 = __c2; }
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=this@entry=0x7fffffffdc50,
    __beg=0x55555576e740 "#", __end=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=1, this=0x7fffffffdc50)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:232
232             _M_set_length(__dnew);
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length (this=0x7fffffffdc50, __length=1)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:214
214           _M_set_length(size_type __n)
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length (__n=1, this=0x7fffffffdc50)
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.h:217
217             traits_type::assign(_M_data()[__n], _CharT());
(gdb) step
std::char_traits<char>::assign (__c2=<optimized out>, __c1=@0x7fffffffdc61: 0 '\000')
    at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/char_traits.h:300
300           { __c1 = __c2; }
(gdb) step
hw::strip (s=...) at hw.cc:52
52        size_t i = result.find('\0');
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find (this=this@entry=0x7fffffffdc50, __c=__c@entry=0 '\000',
    __pos=__pos@entry=0) at /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:1228
1228    /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc: No such file or directory.

(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::size (this=this@entry=0x7fffffffdc50)
    at /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:930
930     /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h: No such file or directory.
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find (this=this@entry=0x7fffffffdc50, __c=__c@entry=0 '\000',
    __pos=__pos@entry=0) at /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:186
186     in /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h
(gdb) step
349     /var/tmp/notmpfs/portage/sys-devel/gcc-9.1.0-r1/work/build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h: No such file or directory.
(gdb) step


Again - looking for files in my portage-tmpdir - stepping further I get more of this (but also occurences where it looks for it at
Code:
(gdb) step
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*> (this=this@entry=0x7fffffffdc50,
    __beg=0x555555625f50 "#\tList of PCI ID's", __end=0x555555625f62 "") at /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/bits/basic_string.tcc:206
206           basic_string<_CharT, _Traits, _Alloc>::
)
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Thu Jul 04, 2019 7:32 pm    Post subject: Reply with quote

Currently emerging gcc-8.3.0-r1 - but that's an all night project on this hardware.

Thanks for the help/guiding so far :D
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Jul 05, 2019 1:05 am    Post subject: Reply with quote

Your latest backtrace shows that lshw calls free() in glibc. And free() decides to throw an error:

Code:
File: glibc-2.29/malloc/malloc.c, Line 4161:

static void
_int_free (mstate av, mchunkptr p, int have_lock)
{
  INTERNAL_SIZE_T size;        /* its size */
  mfastbinptr *fb;             /* associated fastbin */
  mchunkptr nextchunk;         /* next contiguous chunk */
  INTERNAL_SIZE_T nextsize;    /* its size */
  int nextinuse;               /* true if nextchunk is used */
  INTERNAL_SIZE_T prevsize;    /* size of previous contiguous chunk */
  mchunkptr bck;               /* misc temp for linking */
  mchunkptr fwd;               /* misc temp for linking */

  size = chunksize (p);

  /* Little security check which won't hurt performance: the
     allocator never wrapps around at the end of the address space.
     Therefore we can exclude some size values which might appear
     here by accident or by "design" from some intruder.  */
  if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0)
      || __builtin_expect (misaligned_chunk (p), 0))
    malloc_printerr ("free(): invalid pointer");         <--- Line 4185, that's where the error is thrown

So either something is wrong with your glibc, or - more likely - lshw calls free() with an invalid pointer. I'm surprised that you couldn't trigger the error in gdb - but maybe I have overlooked something.

One more test. Please run
Code:
ltrace -C -S -e malloc+free-@libc.so* /usr/sbin/lshw 2>/tmp/log

This may take a few seconds. Please post the last 100 lines of /tmp/log using wgetpaste.
Code:
tail -n 100 /tmp/log | wgetpaste
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Fri Jul 05, 2019 4:48 am    Post subject: Reply with quote

ltrace output - http://dpaste.com/2MN1241

Currently running ltrace without a filter, taking quite some time it seems - and /tmp/log currently at +100MB

[EDIT]
and ltrace output without filter - http://dpaste.com/1A50SE9
[/EDIT]
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Jul 05, 2019 11:29 am    Post subject: Reply with quote

Thanks for your ltrace data. I analyzed it and made some tests on my machine. The error happens in function "string hw::strip(const string & s)". The backtrace should look like
Code:
string hw::strip(const string & s) (file: lshw/src/core/hw.cc)
static bool parse_pcidb(vector < string > &list)  (file: src/core/pci.cc)
static bool load_pcidb(vector < string > &list)  (file: src/core/pci.cc)

I don't know why the backtrace doesn't show parse_pcidb() and hw::strip().

Please try:
  1. Open lshw with gdb:
    Code:
    gdb /usr/sbin/lshw

  2. Set a breakpoint at the start of function parse_pcidb()
    Code:
    break parse_pcidb   

  3. Run the program until it reaches the function:
    Code:
    run

  4. Enter
    Code:
    list 434
    which will show 10 lines of source code around line 434. You should see:
    Code:
    ...
    431               if (sscanf(line.c_str(), "%lx", &u[0]) != 1)
    432                 return false;
    433               line = line.substr(5);
    434               line = hw::strip(line);
    ...

  5. Set a breakpoint on line 434, continue to that line and print the variable 'line'
    Code:
    break 434
    c
    print line

    You should see " SafeNet (wrong ID)", right?

  6. Open the second ltrace you posted and search for that string.
    Code:
    __isoc99_sscanf(0x55bff0eaab10, 0x55bfeef314c9, 0x7ffc7ad93ed0, 24)                                = 1
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)(0x7ffc7ad94030, 0x7ffc7ad93e20, 0, 0) = 0x55bff0eaaac0
    memcpy(0x55bff0eaaac0, " SafeNet (wrong ID)", 19)                                                  = 0x55bff0eaaac0
    operator delete(void*)(0x55bff0eaab10, 30, 19, 19)                                                 = 0
    std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)(0x7ffc7ad94010, 0x7ffc7ad93da0, 0, 0x55bff0bfd010) = 0x55bff0eaadd0
    memcpy(0x55bff0eaadd0, " SafeNet (wrong ID)", 19)                                                  = 0x55bff0eaadd0

    There's the call to sscanf(). Do you see it? We are close!

  7. Now step through function hw::strip() until the error occurs (you will see a call to glibc._int_free() and then to malloc_printerr()
    Code:
    step

    Some lines of the output will be similar to the output in your second ltrace file.

  8. Please post the output of your gdb session using wgetpaste.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Fri Jul 05, 2019 3:28 pm    Post subject: Reply with quote

mike155 wrote:

[*]Set a breakpoint on line 434, continue to that line and print the variable 'line'
Code:
break 434
c
print line

You should see " SafeNet (wrong ID)", right?

[*]Open the second ltrace you posted and search for that string.
Code:
__isoc99_sscanf(0x55bff0eaab10, 0x55bfeef314c9, 0x7ffc7ad93ed0, 24)                                = 1
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)(0x7ffc7ad94030, 0x7ffc7ad93e20, 0, 0) = 0x55bff0eaaac0
memcpy(0x55bff0eaaac0, " SafeNet (wrong ID)", 19)                                                  = 0x55bff0eaaac0
operator delete(void*)(0x55bff0eaab10, 30, 19, 19)                                                 = 0
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)(0x7ffc7ad94010, 0x7ffc7ad93da0, 0, 0x55bff0bfd010) = 0x55bff0eaadd0
memcpy(0x55bff0eaadd0, " SafeNet (wrong ID)", 19)                                                  = 0x55bff0eaadd0

There's the call to sscanf(). Do you see it? We are close!

[*]Now step through function hw::strip() until the error occurs (you will see a call to glibc._int_free() and then to malloc_printerr()
Code:
step

Some lines of the output will be similar to the output in your second ltrace file.

[*]Please post the output of your gdb session using wgetpaste.


Thanks a lot - here's a snippet (full wgetpaste here - https://pastebin.com/uEcQYndr)

Code:
__GI___libc_free (mem=0x7fffffffdc80) at malloc.c:3094
3094    {
(gdb)
3099        = atomic_forced_read (__free_hook);
(gdb)
3100      if (__builtin_expect (hook != NULL, 0))
(gdb)
3106      if (mem == 0)                              /* free(0) has no effect */
(gdb)
3109      p = mem2chunk (mem);
(gdb)
3111      if (chunk_is_mmapped (p))                       /* release mmapped memory. */
(gdb)
3129      MAYBE_INIT_TCACHE ();
(gdb)
3131      ar_ptr = arena_for_chunk (p);
(gdb)
3132      _int_free (ar_ptr, p, 0);
(gdb)
_int_free (av=0x7ffff7d14aa0 <main_arena>, p=0x7fffffffdc70, have_lock=0) at malloc.c:4163
4163    {
(gdb)
4173      size = chunksize (p);
(gdb)
4179      if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0)
(gdb)
4181        malloc_printerr ("free(): invalid pointer");
(gdb)
malloc_printerr (str=str@entry=0x7ffff7cddc22 "free(): invalid pointer") at malloc.c:5351
5351    {
(gdb)
5352      __libc_message (do_abort, "%s\n", str);
(gdb)
__libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7cdfac8 "%s\n") at ../sysdeps/posix/libc_fatal.c:72
72        va_start (ap, fmt);
(gdb)
80        if ((action & do_backtrace))
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Fri Jul 05, 2019 5:58 pm    Post subject: Reply with quote

Just found out that lshw is actually working on two (or rather - now one) of my servers (identical hardware/configuration).

I tried re-emerging lshw on one - and now same error.....

I think it might be time to crawl through emerge-logs and compare/see what packages have been updated after lshw was last emerged on the remaining working server....

It seems like I was at gcc-8.1.0-r1 and glibc-2.27-r2 at the time of last updating lshw on that server.

The binary from my working server works fine when copied to the four others.

[EDIT]
Thinking about it - that's actually a bit worrying?

That means that the environment in some way is the problem?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21861

PostPosted: Sat Jul 06, 2019 12:19 am    Post subject: Reply with quote

Some program bugs are environment specific. For example, if only the systems where it fails have a PCI network card, and the bug is triggered by trying to describe PCI network cards, then the other systems would seem fine.

Have you checked whether valgrind can show you the origin of the error? Although it runs slowly, it often provides very good guidance.
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Sat Jul 06, 2019 12:03 pm    Post subject: Reply with quote

Valgrind-output here - https://pastebin.com/45BxNPe8

Code:
==19216== Memcheck, a memory error detector
==19216== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==19216== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==19216== Command: /usr/sbin/lshw
==19216==
==19216== Invalid free() / delete / delete[] / realloc()
==19216==    at 0x4837E73: operator delete(void*) (vg_replace_malloc.c:576)
==19216==    by 0x160C37: deallocate (new_allocator.h:128)
==19216==    by 0x160C37: deallocate (alloc_traits.h:470)
==19216==    by 0x160C37: _M_destroy (basic_string.h:237)
==19216==    by 0x160C37: _M_dispose (basic_string.h:232)
==19216==    by 0x160C37: ~basic_string (basic_string.h:658)
==19216==    by 0x160C37: ~pci_entry (pci.cc:232)
==19216==    by 0x160C37: parse_pcidb (pci.cc:503)
==19216==    by 0x160C37: load_pcidb() (pci.cc:520)
==19216==    by 0x1668E1: scan_pci(hwNode&) (pci.cc:1094)
==19216==    by 0x13E001: scan_system(hwNode&) (main.cc:89)
==19216==    by 0x12970A: main (lshw.cc:233)
==19216==  Address 0x1ffefffc30 is on thread 1's stack
==19216==  in frame #1, created by load_pcidb() (new_allocator.h:511)

This is probably my error?
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Sat Jul 06, 2019 2:17 pm    Post subject: Reply with quote

A simple make of the source-code actually produces a working binary.

This means that I should take a closer look at flags in /etc/portage/make.conf?

Code:
CFLAGS="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize"
CXXFLAGS="-fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize -fno-delete-null-pointer-checks -flifetime-dse=1"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -fgraphite-identity -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block -flto=5 -fuse-linker-plugin -fno-fat-lto-objects -O2 -pipe -march=native -fomit-frame-pointer -ftree-vectorize -fno-delete-null-pointer-checks -flifetime-dse=1"
CPU_FLAGS_X86="aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3"


Narrowed it down to flags.... (just had a succesful emerge with a working binary with most flags disabled...

Currently enabling one-by-one to figure out which
Back to top
View user's profile Send private message
freke
Veteran
Veteran


Joined: 23 Jan 2003
Posts: 1000
Location: Somewhere in Denmark

PostPosted: Sat Jul 06, 2019 3:14 pm    Post subject: Reply with quote

Pinpointed!

Code:
-fno-delete-null-pointer-checks
in my flags caused it - thought I picked it and
Code:
-flifetime-dse=1
up from some LTO/Graphite guide, but I see it was also in my no-lto-no-graphite.conf flags....

After removing this flag my emerged lshw now works fine again.


Thanks for taking your time to help/guide me through debugging processes with gdb/valgrind
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum