Skip to content

Segmentation fault with ASAN #1071

@ybogo

Description

@ybogo

Add a description

Adding compiler flags -fsanitize=address -fno-omit-frame-pointer leading to immediate segfault on any run.

Steps to reproduce:

  1. Build project samples with ASAN flags
mkdir build_debug
cmake -DCMAKE_BUILD_TYPE=Debug -DUSERVER_BUILD_SAMPLES=ON -DCMAKE_C_FLAGS_INIT:STRING="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS_INIT:STRING="-fsanitize=address -fno-omit-frame-pointer" ..
make
  1. Run any sample using gdb
gdb ./samples/hello_service/userver-samples-hello_service
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 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 "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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 ./samples/hello_service/userver-samples-hello_service...
warning: File "/root/userver/build_debug/samples/hello_service/userver-samples-hello_service" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
	add-auto-load-safe-path /root/userver/build_debug/samples/hello_service/userver-samples-hello_service
line to your configuration file "/root/.config/gdb/gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/root/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
warning: File "/root/userver/build_debug/samples/hello_service/userver-samples-hello_service" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
(gdb) r
Starting program: /root/userver/build_debug/samples/hello_service/userver-samples-hello_service
warning: could not find '.gnu_debugaltlink' file for /lib/aarch64-linux-gnu/libboost_stacktrace_backtrace.so.1.83.0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
warning: could not find '.gnu_debugaltlink' file for /lib/aarch64-linux-gnu/liblber.so.2
warning: could not find '.gnu_debugaltlink' file for /lib/aarch64-linux-gnu/libbrotlidec.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/aarch64-linux-gnu/libbrotlicommon.so.1

Program received signal SIGSEGV, Segmentation fault.
0x0000aaaaab34c4fc in userver::v2_14_rc::engine::impl::(anonymous namespace)::DlIteratePhdr (callback=0xfffff7985aa0 <__asan::FindFirstDSOCallback(dl_phdr_info*, size_t, void*)>,
    data=0xfffffffff460) at /root/userver/core/src/engine/task/exception_hacks.cpp:179
179	int DlIteratePhdr(DlIterateCb callback, void* data) {
(gdb) bt
#0  0x0000aaaaab34c4fc in userver::v2_14_rc::engine::impl::(anonymous namespace)::DlIteratePhdr (callback=0xfffff7985aa0 <__asan::FindFirstDSOCallback(dl_phdr_info*, size_t, void*)>,
    data=0xfffffffff460) at /root/userver/core/src/engine/task/exception_hacks.cpp:179
#1  0x0000aaaaab34cf7c in dl_iterate_phdr (callback=0xfffff7985aa0 <__asan::FindFirstDSOCallback(dl_phdr_info*, size_t, void*)>, data=0xfffffffff460)
    at /root/userver/core/src/engine/task/exception_hacks.cpp:265
#2  0x0000fffff7985eb8 in __asan::AsanCheckDynamicRTPrereqs () at ../../../../src/libsanitizer/asan/asan_linux.cpp:172
#3  0x0000fffff7995190 [PAC] in __asan::AsanInitInternal () at ../../../../src/libsanitizer/asan/asan_rtl.cpp:417
#4  0x0000fffff7fc2c98 [PAC] in _dl_init (main_map=0xfffff7fff350, argc=1, argv=0xfffffffff548, env=0xfffffffff558) at ./elf/dl-init.c:106
#5  0x0000fffff7fd8a78 in _start () at ../sysdeps/aarch64/dl-start.S:46

Env

OS: docker image ubuntu-24.04-base
Userver commit: f43a5fe557ea01a983152e486987710c2f100356

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions