Bug 465916 - Valgrind crashing with segmentation fault
Summary: Valgrind crashing with segmentation fault
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.20.0
Platform: Android Android 11.x
: NOR crash
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-17 11:57 UTC by ramesh k
Modified: 2023-02-24 07:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ramesh k 2023-02-17 11:57:25 UTC
SUMMARY
Hi,
 I cross compile valgrind version 3.20 and tried to run on android 11 device.
<path>/data/local/Inst/bin # ./valgrind --help
Segmentation fault

STEPS TO REPRODUCE
1. export NDKROOT=<NDK local path>
2. 
export AR=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar 
export LD=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld
export CC=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang
export CXX=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++

3.
./autogen.sh

4.
CPPFLAGS="--sysroot=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot" \
   CFLAGS="--sysroot=$NDKROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot" \
   ./configure --prefix=/data/local/Inst \
   --host=aarch64-linux  --target=aarch64-linux-android\
   --with-tmpdir=/data/local/tmp --enable-only64bit

5. make -j4
6. make -j4 install DESTDIR=`pwd`/Inst
7. push binaries to android device
8. run valgrind executable

OBSERVED RESULT
segmentation fault

EXPECTED RESULT

help menu

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Ubunt 18.04 (host for cross compilation)
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Paul Floyd 2023-02-17 16:26:26 UTC
Can you post the output?
Do verbose/debug options help (like -d -d -d -v -v -v)?
Comment 2 Paul Floyd 2023-02-21 05:56:48 UTC
Reminder
Comment 3 ramesh k 2023-02-23 12:05:11 UTC
Sorry for late response. Please find the log with -d option

lahaina:/data/local/tmp/ramesh/Inst/data/local/Inst/bin # ./valgrind -d --help
--10869:1:debuglog DebugLog system started by Stage 1, level 1 logging requested
--10869:1:launcher no tool requested, defaulting to 'memcheck'
--10869:1:launcher no client specified, defaulting platform to 'arm64-linux'
--10869:1:launcher launching /data/local/tmp/ramesh/data/local/Inst/libexec/valgrind/memchSegmentation fault
139|lahaina:/data/local/tmp/ramesh/Inst/data/local/Inst/bin #
Comment 4 ramesh k 2023-02-23 12:14:52 UTC
I moved valgrind bin folder to different location and I am getting below log

139|lahaina:/data/local/Inst/bin # ./valgrind -d --help
--12517:1:debuglog DebugLog system started by Stage 1, level 1 logging requested
--12517:1:launcher no tool requested, defaulting to 'memcheck'
--12517:1:launcher no client specified, defaulting platform to 'arm64-linux'
--12517:1:launcher launching /data/local/Inst/libexec/valgrind/memcheck-arm64-linux
--12517:1:debuglog DebugLog system started by Stage 2 (main), level 1 logging requested
--12517:1:    main Welcome to Valgrind version 3.20.0 debug logging
--12517:1:    main Checking current stack is plausible
--12517:1:    main Checking initial stack was noted
--12517:1:    main Starting the address space manager
--12517:1:    main Address space manager is running
--12517:1:    main Starting the dynamic memory manager
--12517:1:mallocfr newSuperblock at 0x1002001000 (pszB 4194272)  owner VALGRIND/core
--12517:1:mallocfr deferred_reclaimSuperblock at 0x1002001000 (pszB 4194272)  (prev 0x0) oSegmentation fault
Comment 5 Paul Floyd 2023-02-24 07:14:48 UTC
You should also be able to run Valgrind from your build directory with

./vg-in-place

Your crash is quite early in Valgrind startup. I don't use android at all so I can't help much.

Can you debug Valgrind as per the instructions in README_DEVELOPERS?