grpc / grpc/grpc

[CORE] crash of grpc Metric name has already been registered with ASAN enabled

Open
#43,050 7 comments 0 reactions 1 assignee Claimed by @aadikapur View on GitHub
kind/bug lang/core priority/P2 untriaged
Dominant language
C++
Stars
45.3k
Forks
11.4k
Avg merge
2d 12h
Merged PRs (30d)
47

Description

### What version of gRPC and what language are you using?
1.82.1 c++

### What operating system (Linux, Windows,...) and version?
Ubuntu 24.04.4 LTS \n \l

### What runtime / compiler are you using (e.g. python version or version of gcc)
gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

### What did you do?
Compiling project with grpc 1.82.1 and running asan cheks

### What did you expect to see?
Normal application start

### What did you see instead?
```
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007fffed84527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007fffed8288ff in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff36ce5c7 in grpc_core::Crash (message=..., location=...) at /ext/fastcache/cmake-build-debug/_deps/grpc-src/src/core/util/crash.cc:30
#6 0x00007ffff4dd96b5 in grpc_core::GlobalInstrumentsRegistry::RegisterInstrument (value_type=value_type@entry=grpc_core::GlobalInstrumentsRegistry::ValueType::kUInt64, instrument_type=instrument_type@entry=grpc_core::GlobalInstrumentsRegistry::InstrumentType::kCounter, name=..., description=..., unit="{resource}", enable_by_default=, label_keys=..., optional_label_keys=...) at /ext/fastcache/cmake-build-debug/_deps/grpc-src/src/core/telemetry/metrics.cc:49
#7 0x00007ffff4f53351 in grpc_core::GlobalInstrumentsRegistry::RegistrationBuilder<(grpc_core::GlobalInstrumentsRegistry::ValueType)2, (grpc_core::GlobalInstrumentsRegistry::InstrumentType)1, 3ul, 0ul>::Build (this=this@entry=0x7fffffffdb20) at /ext/fastcache/cmake-build-debug/_deps/grpc-src/src/core/telemetry/metrics.h:127
#8 0x00007ffff370fa39 in __static_initialization_and_destruction_0 () at /ext/fastcache/cmake-build-debug/_deps/grpc-src/src/core/xds/grpc/xds_client_grpc.cc:105
#9 0x00007ffff3711c4a in _GLOBAL__sub_I_xds_client_grpc.cc(void) () at /ext/fastcache/cmake-build-debug/_deps/grpc-src/src/core/xds/grpc/xds_client_grpc.cc:488
#10 0x00007ffff7fca71f in call_init (l=, argc=argc@entry=3, argv=argv@entry=0x7fffffffdde8, env=env@entry=0x7fffffffde08) at ./elf/dl-init.c:74
#11 0x00007ffff7fca824 in call_init (env=, argv=, argc=, l=) at ./elf/dl-init.c:120
#12 _dl_init (main_map=0x7ffff7ffe2e0, argc=3, argv=0x7fffffffdde8, env=0x7fffffffde08) at ./elf/dl-init.c:121
#13 0x00007ffff7fe45a0 in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#14 0x0000000000000003 in ?? ()
#15 0x00007fffffffe295 in ?? ()
#16 0x00007fffffffe2dd in ?? ()
#17 0x00007fffffffe2ea in ?? ()
#18 0x0000000000000000 in ?? ()
```

See [TROUBLESHOOTING.md](https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md) for how to diagnose problems better.

### Anything else we should know about your project / environment?
Compiling with Debug config
```
add_compile_options("$<$:-g>")
add_compile_options("$<$:-O3>") # tried wiht 01 02 03
add_compile_options("$<$:-msse4.2>")
add_compile_options("$<$:-mbmi2>")
add_compile_options("$<$:-mbmi>")
add_compile_options("$<$:-fno-plt>")
add_compile_options("$<$:-fsanitize=address>")
add_compile_options("$<$:-ftls-model=initial-exec>")
add_compile_options("$<$:-fno-omit-frame-pointer>")
```
Application has 3 grpc services they should start sequentially
Compiling and run with RELEASE no problems observed
```
add_compile_options("$<$:-O3>")
add_compile_options("$<$:-msse4.2>")
add_compile_options("$<$:-mbmi2>")
add_compile_options("$<$:-mbmi>")
add_compile_options("$<$:-g>")
add_compile_options("$<$:-fno-plt>")
add_compile_options("$<$:-funroll-loops>")
add_compile_options("$<$:-fprefetch-loop-arrays>")
add_compile_options("$<$:-ftls-model=initial-exec>") # Ускоряем thread_local
add_compile_options("$<$:-fno-semantic-interposition>")
add_compile_options("$<$:-falign-functions=32>")
add_compile_options("$<$:-falign-loops=32>")
add_compile_options("$<$:-fno-omit-frame-pointer>")
add_compile_options("$<$:-fstrict-aliasing>")
```
grpc integration via cmake
```
include(FetchContent)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_POLICY_VERSION_MINIMUM 3.5)

cmake_policy(SET CMP0069 NEW)
set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)

set(gRPC_ABSL_PROVIDER "module" CACHE STRING "" FORCE)
set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "" FORCE)
set(gRPC_RE2_PROVIDER "module" CACHE STRING "" FORCE)

set(gRPC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(gRPC_BENCHMARK_PROVIDER "none" CACHE STRING "" FORCE)
set(gRPC_BUILD_CSHARP_EXT OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_PYTHON_EXT OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_NODE_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_PHP_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_RUBY_PLUGIN OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPC_CPP_PLUGIN ON CACHE BOOL "" FORCE)
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_GRPCPP_OTEL OFF CACHE BOOL "" FORCE)
set(gRPC_BUILD_XDS_CONFIG OFF CACHE BOOL "" FORCE)
set(gRPC_ENABLE_STATS OFF CACHE BOOL "" FORCE)
set(gRPC_XDS_USER_AGENT_IS_CSHARP OFF CACHE BOOL "" FORCE)

macro(original_install)
_install(${ARGV})
endmacro()

macro(install)
endmacro()

FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc.git
GIT_TAG v1.82.1
)
FetchContent_MakeAvailable(gRPC)

macro(install)
original_install(${ARGV})
endmacro()

if(NOT TARGET gRPC::grpc++)
add_library(gRPC::grpc++ ALIAS grpc++)
endif()

if(NOT TARGET protobuf::libprotobuf)
add_library(protobuf::libprotobuf ALIAS libprotobuf)
endif()

if(NOT TARGET protobuf::protoc)
add_library(protobuf::protoc ALIAS protoc)
endif()
```

In general i need to run asan on my project. I suspect some problems because of ASAN.
Issue reproduced with ASAN only

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.