Re: armhf: illegal hardware instruction

Mathieu Malaterre <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Message-ID <CA+7wUszXfjeLpFpfhbH2+E8uVno1P28PJy0HGXPeYmyyY_4oxg@mail.gmail.com>
On Tue, Jun 28, 2022 at 4:54 PM John Reiser <[email protected]> wrote:
>
> track down Debian issue https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=928224
> which is 3 years old:
> -----
> Installed libc6 version: libc6-dgb:armhf 2.28-8
>
> valgrind /bin/true
>
> ==12463== Memcheck, a memory error detector
> ==12463== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==12463== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
> valgrind:  Fatal error at startup: a function redirection
> valgrind:  which is mandatory for this platform-tool combination
> valgrind:  cannot be set up.  Details of the redirection are:
> valgrind:
> valgrind:  A must-be-redirected function
> valgrind:  whose name matches the pattern:      index
> valgrind:  in an object with soname matching:   ld-linux-armhf.so.3
> valgrind:  was not found whilst processing
> valgrind:  symbols from the object with soname: ld-linux-armhf.so.3
> -----
>
> Using valgrind 3.19.0 on Debian/sid :
> % dpkg --print-architecture
> armhf
> % cat /proc/cpuinfo | grep vfpv3 | head -1
> Features        : half thumb fastmult vfp edsp thumbee vfpv3 tls idiva
> idivt vfpd32 lpae
> > % ./memcheck/memcheck-arm-linux
> > zsh: illegal hardware instruction  ./memcheck/memcheck-arm-linux
> >
> > Just in case that help, here is the gdb output (*)
> >
> > Let me know if you need more output.
> >
> > (*)
> > % gdb ./memcheck/memcheck-arm-linux
> > GNU gdb (Debian 12.1-2) 12.1
>
> > (gdb) r
> > Starting program: /home/malat/valgrind-3.19.0/memcheck/memcheck-arm-linux
> >
> > Program received signal SIGILL, Illegal instruction.
> > vgPlain_am_startup (sp_at_startup=3204445840) at
> > m_aspacemgr/aspacemgr-linux.c:1626
> > 1626       init_nsegment(&seg);
> > (gdb) bt full
> > #0  vgPlain_am_startup (sp_at_startup=3204445840) at
> > m_aspacemgr/aspacemgr-linux.c:1626
> >          seg = {kind = 0, start = 0, end = 0, smode = SmLower, dev = 0,
> > ino = 0, offset = 5378467285696512, mode = 3204445844, fnIdx =
> > -1090521456, hasR = 0 '\000', hasW = 0 '\000', hasX = 38 '&',
> >            hasT = 88 'X', isCH = 164 '\244'}
> >          suggested_clstack_end = <optimized out>
> >          __PRETTY_FUNCTION__ = "vgPlain_am_startup"
>
>
> I tried to reproduce the reported behavior of valgrind-3.19.0 on my system :
> ----- /proc/cpuinfo
> model name      : ARMv7 Processor rev 4 (v7l)
> BogoMIPS        : 51.20
> Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
> CPU implementer : 0x41
> CPU architecture: 7
> CPU variant     : 0x0
> CPU part        : 0xd03
> CPU revision    : 4
> -----
> $ uname -a
> Linux f33arm32 5.9.14-200.fc33.armv7hl #1 SMP Fri Dec 11 15:02:36 UTC 2020 armv7l armv7l armv7l GNU/Linux
> $ ldd /bin/date
>         libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6f6a000)
>         libc.so.6 => /lib/libc.so.6 (0xb6e14000)
>         /lib/ld-linux-armhf.so.3 (0xb6fbe000)
>
> So the name of ld-linux contains 'armhf', although the Linux kernel is 'armv7l'.
> The Features line of /proc/cpuinfo is not quite equivalent:
> Mathieu's: half thumb fastmult vfp edsp thumbee vfpv3 tls       idiva idivt vfpd32 lpae
> mine:      half thumb fastmult vfp edsp neon    vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
>
> Re-building the software:
> -----
> $ wget https://sourceware.org/pub/valgrind/valgrind-3.19.0.tar.bz2
> $ tar xf valgrind-3.19.0.tar.bz2
> $ cd valgrind-3.19.0
> $ ./configure
> $ make -j4
> $ file ./memcheck/memcheck-arm-linux
> ./memcheck/memcheck-arm-linux: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=2880b8ee178c482a9de58e83b161a0b38ca008ff, with debug_info, not stripped
> $ ./memcheck/memcheck-arm-linux
> valgrind: You cannot run './memcheck/memcheck-arm-linux' directly.
> valgrind: You should use $prefix/bin/valgrind.
> $ sudo make install
> $ /usr/local/bin/valgrind --version
> valgrind-3.19.0
> $ /usr/local/bin/valgrind /bin/date
> ==14541== Memcheck, a memory error detector
> ==14541== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
> ==14541== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
> ==14541== Command: /bin/date
> ==14541==
> Tue Jun 28 07:40:14 AM PDT 2022
> ==14541==
> ==14541== HEAP SUMMARY:
> ==14541==     in use at exit: 0 bytes in 0 blocks
> ==14541==   total heap usage: 427 allocs, 427 frees, 30,017 bytes allocated
> ==14541==
> ==14541== All heap blocks were freed -- no leaks are possible
> ==14541==
> ==14541== For lists of detected and suppressed errors, rerun with: -s
> ==14541== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
> $
> -----
>
> So, valgrind-3.19.0 works for me.  I cannot reproduce the original bad behavior, nor the SIGILL,
> on my hardware running 5.9.14-200.fc33.armv7hl.

Ok, thanks for the quick answer. I discovered that I was supposed to
run 'vg-in-place' when not using make install.

Here is my strace output (*)

> If you believe that my Fedora33 environment is not close enough to your Debian/sid,
> then please give the URL of a raw image for RaspberryPi Model 3 V1.2 that I can install
> on a 32GB SDHC card.

Can you try:

$ export RPI_MODEL=3
$ export DEBIAN_RELEASE=bullseye
$ wget https://raspi.debian.net/daily/raspi_${RPI_MODEL}_${DEBIAN_RELEASE}.img.xz

See complete instructions at:

https://wiki.debian.org/RaspberryPiImages

Thanks -again-

(*) this is from a git/master as of today:

% strace ./vg-in-place
execve("./vg-in-place", ["./vg-in-place"], 0xbe95c740 /* 19 vars */) = 0
brk(NULL)                               = 0x1bbd000
uname({sysname="Linux", nodename="abel", ...}) = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb6fbb000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH,
STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_attributes=0,
stx_mode=S_IFREG|0644, stx_size=17519, ...}) = 0
mmap2(NULL, 17519, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6fb6000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6",
O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0y}\1\0004\0\0\0"...,
512) = 512
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH,
STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_attributes=0,
stx_mode=S_IFREG|0755, stx_size=983540, ...}) = 0
mmap2(NULL, 1073552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0xb6e8a000
mprotect(0xb6f77000, 61440, PROT_NONE)  = 0
mmap2(0xb6f86000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xec000) = 0xb6f86000
mmap2(0xb6f89000, 29072, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f89000
close(3)                                = 0
set_tls(0xb6fbbe20)                     = 0
mprotect(0xb6f86000, 8192, PROT_READ)   = 0
mprotect(0x4ee000, 4096, PROT_READ)     = 0
mprotect(0xb6fbd000, 4096, PROT_READ)   = 0
munmap(0xb6fb6000, 17519)               = 0
getuid32()                              = 3180
getgid32()                              = 3180
getpid()                                = 7762
rt_sigaction(SIGCHLD, {sa_handler=0x4d9db9, sa_mask=~[RTMIN RT_1],
sa_flags=SA_RESTORER, sa_restorer=0xb6eb1fd1}, NULL, 8) = 0
geteuid32()                             = 3180
brk(NULL)                               = 0x1bbd000
brk(0x1bde000)                          = 0x1bde000
getppid()                               = 7759
statx(AT_FDCWD, "/home/malat/valgrind",
AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_BASIC_STATS,
{stx_mask=STATX_ALL, stx_attributes=0, stx_mode=S_IFDIR|0755,
stx_size=4096, ...}) = 0
statx(AT_FDCWD, ".", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT,
STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_attributes=0,
stx_mode=S_IFDIR|0755, stx_size=4096, ...}) = 0
openat(AT_FDCWD, "./vg-in-place", O_RDONLY|O_LARGEFILE) = 3
fcntl64(3, F_DUPFD, 10)                 = 10
close(3)                                = 0
fcntl64(10, F_SETFD, FD_CLOEXEC)        = 0
geteuid32()                             = 3180
getegid32()                             = 3180
rt_sigaction(SIGINT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGINT, {sa_handler=0x4d9db9, sa_mask=~[RTMIN RT_1],
sa_flags=SA_RESTORER, sa_restorer=0xb6eb1fd1}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGQUIT, {sa_handler=SIG_DFL, sa_mask=~[RTMIN RT_1],
sa_flags=SA_RESTORER, sa_restorer=0xb6eb1fd1}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=SIG_DFL, sa_mask=~[RTMIN RT_1],
sa_flags=SA_RESTORER, sa_restorer=0xb6eb1fd1}, NULL, 8) = 0
read(10, "#!/bin/sh\n\n# Figure out an absol"..., 8192) = 691
statx(AT_FDCWD, "./vg-in-place",
AT_STATX_SYNC_AS_STAT|AT_SYMLINK_NOFOLLOW|AT_NO_AUTOMOUNT,
STATX_BASIC_STATS, {stx_mask=STATX_ALL, stx_attributes=0,
stx_mode=S_IFREG|0755, stx_size=691, ...}) = 0
pipe([3, 4])                            = 0
clone(child_stack=NULL,
flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,
child_tidptr=0xb6fbb948) = 7763
close(4)                                = 0
read(3, "/home/malat/valgrind/.\n", 128) = 23
read(3, "", 128)                        = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=7763,
si_uid=3180, si_status=0, si_utime=0, si_stime=0} ---
sigreturn({mask=[]})                    = 0
close(3)                                = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 7763
wait4(-1, 0xbeeca264, WNOHANG, NULL)    = -1 ECHILD (No child processes)
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], NULL, 8) = 0
vfork()                                 = 7764
rt_sigprocmask(SIG_SETMASK, [], ~[KILL STOP RTMIN RT_1], 8) = 0
wait4(-1, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGILL}], 0, NULL) = 7764
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=7764,
si_uid=3180, si_status=SIGILL, si_utime=0, si_stime=0} ---
sigreturn({mask=[]})                    = 7764
write(2, "Illegal instruction\n", 20Illegal instruction
)   = 20
wait4(-1, 0xbeeca394, WNOHANG, NULL)    = -1 ECHILD (No child processes)
read(10, "", 8192)                      = 0
exit_group(132)                         = ?
+++ exited with 132 +++
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.