Hello Dave,
I am not involved in packaging lshw, just looking
at some random crash bug reports.

First, when reporting crashes that line from dmesg is most
of the time not sufficient. Therefore a simple way to retrieve
some more information could be to run it by 'catchsegv lshw'.

Better woudl be if it is possible to install something like
systemd-coredump. That way a backtrace should be printed to
'journalctl --no-pager'.

And even better would be to install additionally matching
dbgsym packages e.g. lshw-dbgsym.
Therefore another package repository is needed to be activated.
More details in [1].

----

But as lshw is small enough, I guess I found something.
The instruction offset in combination with the 'divide error'
points to this line:

(gdb) list fat.cc:220
227             cluster_count /= vs.sectors_per_cluster;

Could you confirm to have a FAT partition attached to the system?
Maybe a damaged or ancient one, maybe a floppy?

If vs.sectors_per_cluster would be 0 the crash would happen
exactly like you experienced it.

(gdb) bt
#0  0x00005555555f2e73 in scan_fat (n=..., id=...) at fat.cc:237
#1  0x00005555555edea4 in detect_fat (n=..., s=...) at volumes.cc:513
#2  0x00005555555eb895 in scan_volume (n=..., s=...) at volumes.cc:1075
#3  0x00005555555e4115 in detect_dosmap (s=..., n=...) at partitions.cc:1197
#4  0x00005555555e0e96 in scan_partitions (n=...) at partitions.cc:1386
#5  0x00005555555cb00a in scan_disk (n=...) at disk.cc:79
#6  0x00005555555c81d5 in scan_sg (n=...) at scsi.cc:762
#7  0x00005555555c9e75 in scan_scsi (n=...) at scsi.cc:909
#8  0x000055555558bffd in scan_system (system=...) at main.cc:134
#9  0x000055555557a50c in main (argc=<optimized out>, argv=<optimized out>) at 
lshw.cc:247


Kind regards,
Bernhard

P.S.:
You compiled upstream package lshw-B.02.18.tar.gz and experienced
a crash. I guess that one is fixed in upstream git in the last
commit to usb.cc, which is unrelated to the above issue.
More details at the bottom of attached file.


[1] https://wiki.debian.org/HowToGetABacktrace#Installing_the_debugging_symbols
# Bullseye/testing amd64 qemu VM 2019-12-18


apt update
apt dist-upgrade


apt install systemd-coredump parted dosfstools binutils mc gdb lshw lshw-dbgsym
apt build-dep lshw


mkdir /home/benutzer/source/lshw/orig -p
cd    /home/benutzer/source/lshw/orig
apt source lshw
cd


reboot


#objdump --disassemble /usr/bin/lshw | grep e73:

gdb -q -ex 'set width 0' -ex 'set pagination off' -ex 'b main' -ex 'run' -ex 
'generate-core-file core' -ex 'kill' -ex 'quit' --args /usr/bin/lshw

root@debian:~# gdb -q -ex 'set width 0' -ex 'set pagination off' -ex 'info 
target' -ex 'quit' /usr/bin/lshw --core core | grep -E "is .text$"
80      lshw.cc: Datei oder Verzeichnis nicht gefunden.
        0x0000555555563a40 - 0x00005555555f4071 is .text

root@debian:~# gdb -q -ex 'set width 0' -ex 'set pagination off' -ex 
'disassemble 0x0000555555563a40,0x00005555555f4071' -ex 'quit' /usr/bin/lshw 
--core core | grep "   0x.............e73"
80      lshw.cc: Datei oder Verzeichnis nicht gefunden.
   0x0000555555565e73 <dmi_chassis(unsigned char, hwNode&)+-193581>:    add    
$0x10,%rbx
   0x0000555555567e73 <add_chip_vpd(std::__cxx11::string, std::__cxx11::string, 
std::map<unsigned int, chip_vpd_data*, std::less<unsigned int>, 
std::allocator<std::pair<unsigned int const, chip_vpd_data*> > >&)+-223165>:  
callq  0x555555563400 <_ZdlPv@plt>
   0x000055555556ee73 <probe_ide(hwNode&, std::__cxx11::string 
const&)+-331037>:        callq  0x555555563400 <_ZdlPv@plt>
   0x000055555556fe73 <pcmcia_ident(int, int, hwNode*)+-344973>:        je     
0x55555556fe7a <pcmcia_ident(int, int, hwNode*)+4294622330>
   0x0000555555572e73 <parse_options(int&, char**)+-397757>:    je     
0x555555572e7a <parse_options(int&, char**)+4294569546>
   0x0000555555573e73 <sysfs::entry::byPath(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >)+-418717>:  mov    %rbp,%rdi
   0x000055555557be73 <hw::resource::operator==(hw::resource const&) const+35>: 
cmp    $0x5,%esi
   0x000055555557ce73 <hw::strip(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)+83>:   mov    %rbx,%rdi
   0x000055555557de73 
<hwNode::findChildByBusInfo(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)+179>: je     
0x55555557df30 <hwNode::findChildByBusInfo(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)+368>
   0x000055555558ae73 <std::vector<hwNode, std::allocator<hwNode> 
>::operator=(std::vector<hwNode, std::allocator<hwNode> > const&)+35>:        
mov    (%rsi),%rbx
   0x000055555558de73 <print(hwNode&, bool, int)+3939>: test   %r14b,%r14b
   0x000055555558fe73 <print(hwNode&, bool, int)+12131>:        mov    
$0x16,%edx
   0x0000555555593e73 <get_efi_systab_smbios()+163>:    nopl   0x0(%rax,%rax,1)
   0x000055555559ae73 <dmi_table(u8 const*, int, hwNode&, int, int, 
int)+22915>:        je     0x55555559899e <dmi_table(u8 const*, int, hwNode&, 
int, int, int)+13486>
   0x000055555559be73 <dmi_table(u8 const*, int, hwNode&, int, int, 
int)+27011>:        mov    0x5b0(%rsp),%rdi
   0x00005555555aae73 <std::_Rb_tree<unsigned int, std::pair<unsigned int 
const, std::pair<unsigned int, std::vector<hwNode, std::allocator<hwNode> > > 
>, std::_Select1st<std::pair<unsigned int const, std::pair<unsigned int, 
std::vector<hwNode, std::allocator<hwNode> > > > >, std::less<unsigned int>, 
std::allocator<std::pair<unsigned int const, std::pair<unsigned int, 
std::vector<hwNode, std::allocator<hwNode> > > > > 
>::_M_erase(std::_Rb_tree_node<std::pair<unsigned int const, std::pair<unsigned 
int, std::vector<hwNode, std::allocator<hwNode> > > > >*)+35>:        mov    
0x30(%rbp),%rbx
   0x00005555555abe73 <cpuinfo_arm(hwNode&, std::__cxx11::string, 
std::__cxx11::string)+291>:   lea    0x10(%rbx),%rax
   0x00005555555aee73 <cpuinfo_aarch64(hwNode&, std::__cxx11::string, 
std::__cxx11::string)+19>:        push   %rbp
   0x00005555555b0e73 <scan_cpuinfo(hwNode&)+3123>:     mov    %r15,%rdi
   0x00005555555b3e73 <utf8[abi:cxx11](unsigned short*, long, bool)+163>:       
add    $0x1,%rbx
   0x00005555555b6e73 <load_pcidb()+643>:       callq  0x555555563400 
<_ZdlPv@plt>
   0x00005555555bce73 <scan_pci_dev(pci_dev&, hwNode&)+18147>:  mov    
0xe8(%rsp),%rdx
   0x00005555555c3e73 <scan_cdrom(hwNode&)+2227>:       movb   $0x0,0x26(%rsp)
   0x00005555555c8e73 <scan_sg(hwNode&)+5299>:  rep stos %rax,%es:(%rdi)
   0x00005555555cbe73 <scan_spd(hwNode&)+2099>: mov    %rbx,%r9
   0x00005555555cee73 <scan_network(hwNode&)+9075>:     callq  0x555555581940 
<hwNode::addCapability(std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > const&, std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)>
   0x00005555555cfe73 <scan_network(hwNode&)+13171>:    mov    %r13,0x1e0(%rsp)
   0x00005555555d4e73 <std::_Rb_tree<std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >, 
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>, std::_Identity<std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> > >, std::less<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> > > >::equal_range(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)+467>: mov    
0x10(%r13),%r13
   0x00005555555dbe73 <sysfstobusinfo(std::__cxx11::string const&)+2115>:       
mov    %rbx,%rdi
   0x00005555555dce73 <finddevice(std::__cxx11::string const&, 
std::__cxx11::string const&)+1251>:      jmpq   0x55555557452b 
<finddevice(std::__cxx11::string const&, std::__cxx11::string 
const&)+4294540187>
   0x00005555555dde73 <guessBusInfo(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)+1059>:      mov    
%rbx,%rdi
   0x00005555555dee73 <scan_device(hwNode&, std::__cxx11::string)+1427>:        
mov    %rbx,%r9
   0x00005555555e6e73 <detect_gpt(source&, hwNode&)+11011>:     mov    %r12,%rdi
   0x00005555555ede73 <detect_fat(hwNode&, source&)+1795>:      callq  
0x555555589870 <std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::_M_construct<char const*>(char const*, char const*, 
std::forward_iterator_tag)>
   0x00005555555f2e73 <scan_fat(hwNode&, source&)+451>: div    %ecx

--> maybe the last line ???   The other lines look not much like floating point 
operations ...





(host) truncate -s 400M /tmp/my_usb_disk.img
(qemu) drive_add 0 id=my_usb_disk,if=none,format=raw,file=/tmp/my_usb_disk.img
(qemu) device_add usb-storage,id=my_usb_disk,drive=my_usb_disk



parted /dev/sdX mklabel msdos --script
parted /dev/sdX mkpart primary fat32 0% 100% --script
mkfs.vfat /dev/sdb1


gdb -q --args lshw

set width 0
set pagination off
directory /home/benutzer/source/lshw/orig/lshw-02.18.85/src/core
display/i $pc
b main
run
dele 1
b scan_fat
b *(scan_fat+451)
cont


next
set vs.sectors_per_cluster = 0
detach




submitter:
[  144.814267] traps: lshw[7613] trap divide error ip:55904120ce73 
sp:7fffff42ae30 error:0 in lshw[55904117d000+92000]
0x55904120ce73 - 0x55904117d000 = 0x8FE73

manipulated:
[ 2903.675225] traps: lshw[8809] trap divide error ip:5555555f2e73 
sp:7fffffffdcf0 error:0 in lshw[555555563000+92000]
0x5555555f2e73 - 0x555555563000 = 0x8FE73

--> offset matches 







root@debian:~# coredumpctl list
TIME                            PID   UID   GID SIG COREFILE  EXE
Wed 2019-12-18 19:51:53 CET    8809     0     0   8 present   /usr/bin/lshw

root@debian:~# coredumpctl gdb 8809

(gdb) bt
#0  0x00005555555f2e73 in scan_fat (n=..., id=...) at fat.cc:237
#1  0x00005555555edea4 in detect_fat (n=..., s=...) at volumes.cc:513
#2  0x00005555555eb895 in scan_volume (n=..., s=...) at volumes.cc:1075
#3  0x00005555555e4115 in detect_dosmap (s=..., n=...) at partitions.cc:1197
#4  0x00005555555e0e96 in scan_partitions (n=...) at partitions.cc:1386
#5  0x00005555555cb00a in scan_disk (n=...) at disk.cc:79
#6  0x00005555555c81d5 in scan_sg (n=...) at scsi.cc:762
#7  0x00005555555c9e75 in scan_scsi (n=...) at scsi.cc:909
#8  0x000055555558bffd in scan_system (system=...) at main.cc:134
#9  0x000055555557a50c in main (argc=<optimized out>, argv=<optimized out>) at 
lshw.cc:247










###########
###########  Just trying unrelated upstream crashes
###########



mkdir /home/benutzer/source/lshw/upstream -p
cd    /home/benutzer/source/lshw/upstream
wget https://www.ezix.org/software/files/lshw-B.02.18.tar.gz
tar xvf lshw-B.02.18.tar.gz
cd lshw-B.02.18
make
cd src
./lshw


$ ./lshw
WARNING: you should run this program as super-user.
terminate called after throwing an instance of 'std::length_error'
  what():  cannot create std::vector larger than max_size()
Abgebrochen (Speicherabzug geschrieben)

root@debian:~# coredumpctl list
TIME                            PID   UID   GID SIG COREFILE  EXE
Wed 2019-12-18 20:11:59 CET    8994  1000  1000   6 present   
/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw

root@debian:~# coredumpctl gdb 8994
...
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007fef4499e535 in __GI_abort () at abort.c:79
#2  0x00007fef44bed643 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007fef44bf8fe6 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007fef44bf9051 in std::terminate() () from 
/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007fef44bf92a5 in __cxa_throw () from 
/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007fef44befd9a in std::__throw_length_error(char const*) () from 
/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x0000561abeee1a3c in std::vector<unsigned char, std::allocator<unsigned 
char> >::_S_check_init_len (__n=18446744073709551615, __a=...) at 
/usr/include/c++/9/bits/stl_vector.h:1767
#8  0x0000561abeee191e in std::vector<unsigned char, std::allocator<unsigned 
char> >::vector (this=0x7ffecc9aaea0, __n=18446744073709551615, __a=...) at 
/usr/include/c++/9/bits/stl_vector.h:508
#9  0x0000561abeee0f3d in scan_dmi_sysfs (n=...) at dmi.cc:1836
#10 0x0000561abeee186c in scan_dmi (n=...) at dmi.cc:1950
#11 0x0000561abeecc0f1 in scan_system (system=...) at main.cc:64
#12 0x0000561abeeb382a in main (argc=1, argv=0x7ffecc9ab5a8) at lshw.cc:233

benutzer@debian:~/source/lshw/upstream/lshw-B.02.18/src$ cat 
/sys/firmware/dmi/tables/smbios_entry_point
cat: /sys/firmware/dmi/tables/smbios_entry_point: Keine Berechtigung








root@debian:/home/benutzer/source/lshw/upstream/lshw-B.02.18/src# ./lshw
Speicherzugriffsfehler (Speicherabzug geschrieben)

root@debian:/home/benutzer/source/lshw/upstream/lshw-B.02.18/src# coredumpctl 
list
TIME                            PID   UID   GID SIG COREFILE  EXE
Wed 2019-12-18 20:19:41 CET    9018     0     0  11 present   
/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw


root@debian:/home/benutzer/source/lshw/upstream/lshw-B.02.18/src# coredumpctl 
gdb 9018
           PID: 9018 (lshw)
           UID: 0 (root)
           GID: 0 (root)
        Signal: 11 (SEGV)
     Timestamp: Wed 2019-12-18 20:19:40 CET (33s ago)
  Command Line: ./lshw
    Executable: /home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw
...                
                Stack trace of thread 9018:
                #0  0x00007f314ecd0eb0 _IO_feof (libc.so.6 + 0x79eb0)
                #1  0x000055d8dfe0f5d3 n/a 
(/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw + 0x795d3)
                #2  0x000055d8dfdbe39e n/a 
(/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw + 0x2839e)
                #3  0x000055d8dfda582a n/a 
(/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw + 0xf82a)
                #4  0x00007f314ec7dbbb __libc_start_main (libc.so.6 + 0x26bbb)
                #5  0x000055d8dfda4b1a n/a 
(/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw + 0xeb1a)

...
Reading symbols from 
/home/benutzer/source/lshw/upstream/lshw-B.02.18/src/lshw...
[New LWP 9018]
Core was generated by `./lshw'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  _IO_feof (fp=0x0) at feof.c:35
35      feof.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0  0x00007f314ecd0eb0 in _IO_feof (fp=0x0) at feof.c:35
#1  0x000055d8dfe0f5d3 in scan_usb (n=...) at usb.cc:380
#2  0x000055d8dfdbe39e in scan_system (system=...) at main.cc:118
#3  0x000055d8dfda582a in main (argc=1, argv=0x7ffe05952f68) at lshw.cc:233

[ 4571.752445] lshw[9018]: segfault at 0 ip 00007f314ecd0eb0 sp 
00007ffe05951e28 error 4 in libc-2.29.so[7f314ec7c000+147000]
[ 4571.752454] Code: 66 2e 0f 1f 84 00 00 00 00 00 c3 0f 1f 80 00 00 00 00 41 
8b 40 04 83 e1 cf 8d 70 01 41 89 70 04 89 0f eb 99 66 0f 1f 44 00 00 <8b> 17 49 
89 f8 f6 47 74 80 0f 84 c1 00 00 00 89 d0 25 00 80 00 00

--> Seems to be fixed in upstram git 
https://github.com/lyonel/lshw/commit/7b99d35064230f908551ba65c29264d90f49f246#diff-c65a85b69ed6c2609acb74f51a6ba544



Reply via email to