AddressSanitizer: SEGV in _dl_get_tls_static_info - address-sanitizer

I'm trying to get ASAN working with one program, but anything I did led to ASAN:DEADLYSIGNAL, so I tried to narrow it down and instrument a small test program with only a few compiler options, just to see if it will work at all:
$ cat > test.c <<EOF
int main(void) { return 0; }
EOF
Here's the command line:
$ gcc -g -O0 -fno-omit-frame-pointer -fsanitize=address test.c && ./a.out
ASAN:DEADLYSIGNAL
=================================================================
==5711==ERROR: AddressSanitizer: SEGV on unknown address 0xb7f11e70 (pc 0xb7f11e84 bp 0xb7ab6320 sp 0xbf92368c T16777215)
==5711==The signal is caused by a WRITE memory access.
#0 0xb7f11e83 in _dl_get_tls_static_info (/lib/ld-linux.so.2+0x11e83)
#1 0xb7a24ff9 (/usr/lib/i386-linux-gnu/libasan.so.4+0x101ff9)
#2 0xb7a10f15 (/usr/lib/i386-linux-gnu/libasan.so.4+0xedf15)
#3 0xb7f0f91a (/lib/ld-linux.so.2+0xf91a)
#4 0xb7f00cb9 (/lib/ld-linux.so.2+0xcb9)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/ld-linux.so.2+0x11e83) in _dl_get_tls_static_info
==5711==ABORTING
(The same error I got for the "real" program.)
With -static-libasan the stack trace is just a bit more descriptive:
$ gcc -g -O0 -fno-omit-frame-pointer -fsanitize=address -static-libasan test.c && ./a.out
ASAN:DEADLYSIGNAL
=================================================================
==5719==ERROR: AddressSanitizer: SEGV on unknown address 0xb7fc6e70 (pc 0xb7fc6e84 bp 0x005f91a0 sp 0xbfe77c2c T16777215)
==5719==The signal is caused by a WRITE memory access.
#0 0xb7fc6e83 in _dl_get_tls_static_info (/lib/ld-linux.so.2+0x11e83)
#1 0x560a49 in __sanitizer::InitTlsSize() (/home/gkirilov/test/a.out+0xe9a49)
#2 0x552e05 in __asan::AsanInitInternal() (/home/gkirilov/test/a.out+0xdbe05)
#3 0xb7fc491a (/lib/ld-linux.so.2+0xf91a)
#4 0xb7fb5cb9 (/lib/ld-linux.so.2+0xcb9)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/ld-linux.so.2+0x11e83) in _dl_get_tls_static_info
==5719==ABORTING
Here are some details about the system:
$ uname -a
Linux drinkpad 4.14.0-3-686-pae #1 SMP Debian 4.14.17-1 (2018-02-14) i686 GNU/Linux
$ gcc --version
gcc (Debian 7.3.0-11) 7.3.0
$ /lib/i386-linux-gnu/libc-2.27.so
Compiled by GNU CC version 7.3.0.
libc ABIs: UNIQUE IFUNC
I also tried clang-6 and gcc-8 (which brings ASAN v5 with it), again, with static and shared libasan, and I got the same messages.
Is my platform not supported? But then, I installed all tools from the official Debian repositories.
The home page of ASAN says that it has only been tested on 64-bit Ubuntu, but I think it is outdated, as the table just above it lists both Linux x86 and x86_64.
Am I doing anything wrong or is my platform not supported?

You are facing a known Asan bug (here's Glibc thread
and GCC bug). TLDR is that it fails on Glibc 2.25+ because Glibc changed some internal interfaces that Asan relied upon. Sadly this bug hasn't got enough attention yet.

Related

Running tmux on an M1 Mac in arm64 mode

So I have tmux installed via arm64 homebrew.
I initially compiled alacritty (my favorite terminal emulator) for arm64 manually, so that's running in arm64 mode. uname -a confirms we're in arm64.
Darwin ndo-mbp.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 arm64
Then I installed homebrew which slowly but surely getting arm64 bottles for most popular applications, including tmux (https://github.com/Homebrew/brew/issues/7857). So I installed that from the arm64 shell, it compiled successfully.
If I run file $(which tmux) I get:
/opt/homebrew/bin/tmux: Mach-O 64-bit executable arm64
However, if I launch that tmux binary in my arm64 alacritty, I seem to land in x86_64 mode. Running uname -a from inside that tmux window I get:
Darwin ndo-mbp.local 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 x86_64
Any idea what's going on here? I'm relatively new to Mac OS, so maybe I'm missing something obvious.
I had the same problem.
In the end the solution was in the ~/.tmux.conf, add:
set-option -g default-shell /path/to/arm64/zsh
Then kill and restart tmux:
sudo kill -9 [PID of tmux]
tmux
uname -a then returns arm64.
Now that the M1 CPUs have been around for a while and the community has had time to figure things out, I manually cross compiled Alacritty for arm64 as they don't have official binaries yet (Github Actions apparenlty won't build them yet).
But from there, I was in alacritty in arm64 mode (uname -m == arm64 :thumbsup:) and was then able to remove and reinstall brew and tmux the recommended way from their websites.
Followed all instructions and was good to go. I think just having been a bit early and messing around making manual changes here and there threw the whole thing off.
I do have one unrelated problem now however - and that's that tmux won't start as a non-root user. It just immediately crashes haha. When started with sudo, it opens with my expected config and uname -m confirms it is the arm64 version, however I can't get it to start with my normal user. Anyway, problem for another day!

How to configure sqlite3's tcltests?

For research purposes, I am trying to run the sqlite3 full test suite.
I am running under Linux for this test.
I believe I have installed the correct libraries
sudo apt-get install tcl-dev tk-dev
And when I run the configure command, it finds tcl
checking whether to use an in-ram database for temporary tables... no
checking if executables have the .exe suffix... unknown
checking for Tcl configuration... found /usr/lib/tclConfig.sh
checking for existence of /usr/lib/tclConfig.sh... loading
checking for library containing readline... no
checking for library containing tgetent... no
checking for readline in -lreadline... no
checking readline.h usability... no
Then when I run make test it ends with:
Time: orderby8.test 5080 ms
Time: orderby9.test 291 ms
Makefile:1201: recipe for target 'tcltest' failed
make: *** [tcltest] Killed
It is hard to tell because your question misses important details:
What *nix exactly?
More importantly, which Tcl versions are installed by apt?
How do you obtain the sqlite3 sources incl. test harnesses?
I just tested fine the following:
Ubuntu Xenial
apt-get install tcl tcl-dev (turns out to be 8.6.7)
wget https://www.sqlite.org/2018/sqlite-src-3250200.zip
unzip sqlite-src-3250200.zip
cd sqlite-src-3250200
./configure && make test
... and it succeeds to complete the make test run:
...
Time: orderby7.test 6 ms
Time: orderby8.test 115 ms
Time: orderby9.test 6 ms
Time: oserror.test 49 ms
...
Time: zipfile2.test 10 ms
SQLite 2018-09-25 19:08:10 fb90e7189ae6d62e77ba3a308ca5d683f90bbe633cf681865365b8e92792d1c7
0 errors out of 147094 tests on builda Linux 64-bit little-endian
All memory allocations freed - no leaks
Maximum memory usage: 9278848 bytes
Current memory usage: 0 bytes
Number of malloc() : -1 calls
It seems that oserror.test crashes whatever Tcl in your case.

clGetPlatformIDs(): CL_PLATFORM_NOT_FOUND_KHR Hashcat

i am trying to run hashcat on my Zen Archlinux i am on the 4.15.4-1-zen kernel version. I have an NVIDIA geforce 920MX and an intel i6189DU.
i installed the latest nvidia-dkms drivers and as well as the opencl-nvidia package.
I also installed the latest Hashcat version.
When i run the hashcat command i get this error :clGetPlatformIDs(): CL_PLATFORM_NOT_FOUND_KHR.
I used a tool to determin the openCL platforms available clinfo and the output only shows my CPU platform not my GPU yet the hashcat command still outputs the same erro.
Any help ?
Fellow Archer here, I found a way to fix the broken hashcat as you can see:
$ hashcat -b
hashcat (...) starting in benchmark mode...
clGetPlatformIDs(): CL_PLATFORM_NOT_FOUND_KHR
ATTENTION! No OpenCL-compatible or CUDA-compatible platform found.
You are probably missing the OpenCL or CUDA runtime installation.
$ pacman -S clinfo
$ clinfo
Number of platforms 0
One way to fix it is to install pocl (Portable OpenCL is an open-source implementation of OpenCL):
$ pacman -S pocl
$ clinfo
Number of platforms 1
Platform Name Portable Computing Language
Platform Vendor The pocl project
...
$ hashcat -b
hashcat (...) starting in benchmark mode...
OpenCL API (...) - Platform #1 [The pocl project]
=========================================================================================================================
* Device #1: pthread-Intel(R) ...
Benchmark relevant options:
===========================
* --optimized-kernel-enable
Hashmode: 0 - MD5
Speed.#1.........: ...
...
Happy cracking! ( ͡° ͜ʖ ͡°)
Linuxmint 22.1:
sudo apt-get install pocl-opencl-icd

How long does compiling minix take?

I downloaded the Minix source code through git:
git clone git://git.minix3.org/minix minixsrc
Then I followed the instructions on Crosscompiling MINIX with build.sh
and ran the command
sh build.sh -mi386 -O ../build tools
Now I have been waiting for about an hour for it to compile and it is continuously showing messages on my terminal like this:
# compile libclangSema/SemaExprMember.lo
c++ -O -O2 -fno-rtti -fno-exceptions -I. -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/clang/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/lld/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/llvm/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/mclinker/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/lldb/include -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCLANG_ENABLE_STATIC_ANALYZER -I/home/keeyan/git/minixsrc/../build/tools/llvm-include -I/home/keeyan/git/minixsrc/../build/tools/llvm/config/include -I/home/keeyan/git/minixsrc/../build/tools/llvm/config/tools/clang/include -I/home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../config/mclinker -std=c++11 -std=c++11 -c -o SemaExprMember.lo.o /home/keeyan/git/minixsrc/tools/llvm-lib/libclangSema/../../llvm/../../external/bsd/llvm/lib/../dist/clang/lib/Sema/SemaExprMember.cpp
mv SemaExprMember.lo.o SemaExprMember.lo
My question is, how long should this process take? Is something wrong?
System Specs:
OS: Linux Mint 18 64bit
CPU: Intel Core i7-5500U CPU # 2.4GHz x 2
I believe it should take this long to do the job. It took me about 2 hours for the sh build.sh -mi386 -O ../build tools c to finish and it completed successfully and I got the build tools. After that process I ran the sh build.sh -mi386 -O ../build -U distribution command and that also took a number of hours. I ended up with the built distribution of MINIX which is what was expected of the process. It seems after that there is no way to turn this into an ISO though.
I don't know if the build script unsets MAKEFLAGS but you can do:
MAKEFLAGS=-j\ $(nproc) sh build.sh -mi386 -O ../build tools
nproc returns the number of cores in your CPU so it uses all cores and is faster.

BLAS-LAPACK-ATLAS-R installation with multithreading?

I am trying to setup ATLAS, BLAS, LAPACK, and R on an OpenSuSE 12.2 server with an 8 core AMD athlon FX-8320. I have turned off the CPU frequency scaling using cpufreq and a script cfu from paste.opensuse.org/92162247 made by James McDaniel.
So following the instructions, here http://math-atlas.sourceforge.net/atlas_install/node45.html I didn't need to install gcc (that I know yet) I have gcc (SUSE Linux) 4.7.1 20120723 installed, g++, and gfortran the same version as gcc.
The instructions are to make a bogus configuration of ATLAS to determine the compiler flags to use. ATLAS is configured in the instructions as '../configure -b 64 -D c -DPentiumCPS=2200 -Fa alg -fPIC'. I modify this to what I think will work for my setup ' ../configure -b 64 -t 8 -Fa alg -fpic -A x86_64 -D c -DpentiumCPS=3500 -Si latune 1 --prefix=/usr/local/lib64 --with-netlib-lapack-tarfile=/opt/maths/lapack-3.4.2.tgz' I get these errors.
OS configured as Linux (1)
Assembly configured as GAS_x8664 (2)
Vector ISA Extension configured as AVXMAC (3,504)
ERROR: enum fam=6, chip=8, mach=0
make[3]: *** [atlas_run] Error 44
make[2]: *** [IRunArchInfo_x86] Error 2
/bin/sh: line 1: 13849 Segmentation fault ./xarchinfo_linux -a > config0.out
make[3]: *** [atlas_run] Error 139
make[2]: *** [IRunArchInfo_linux] Error 2
Architecture configured as UNKNOWNx86 (35)
ERROR: enum fam=6, chip=8, mach=0
make[3]: *** [atlas_run] Error 44
make[2]: *** [IRunArchInfo_x86] Error 2
Clock rate configured as 3500Mhz
Parallel make command configured as '$(MAKE) -j 8'
ERROR: enum fam=6, chip=8, mach=0
make[3]: *** [atlas_run] Error 44
make[2]: *** [IRunArchInfo_x86] Error 2
Cannot detect CPU throttling.
Atlas makes a Make.inc and if I fgrep F77 and F77 flags I get 'gfortran-4.7' AND '-O -mavx -fpic -m64'. Maybe the -mavx flag handles the AVXMAC error? Do I need -mavx? I will proceed with my instructions...
(Not a real answer, but difficult to read as a comment):
A few more considerations on Dirk's recommendation to use OpenBLAS.
I also use OpenBLAS (on Ubuntu and CentOS systems).
One consideration that is important for me on the 8 and 12 core machines is that OpenBLAS allows dynamic setting of the number of threads to use, which ATLAS doesn't. In Order to set the number of threads dynamicall from within R, I use Simon Fuller's OpenBLASThreads.
OpenBLAS was pretty straightforward to build on both systems.
Binary .deb packages are available, but last time I checked them, they had the maximum possible number of threads set to 2. However, this is going to change. Till now, I also build the library from source on Ubuntu machines with > 2 cores.

Resources