6 Commits

Author SHA1 Message Date
Felix-Gong e9d4b190fb Fix static initialization order fiasco in AdaptiveMaxConcurrency (#3315)
AdaptiveMaxConcurrency has two class-static std::string members (UNLIMITED
and CONSTANT) defined in adaptive_max_concurrency.cpp. Global
AdaptiveMaxConcurrency objects in other translation units may be constructed
before these static strings are initialized, causing undefined behavior.

This issue was discovered during RISC-V porting and testing of BRPC.
Different toolchains and linkers (GCC, Clang, cross-compilation toolchains
for RISC-V, etc.) may produce different static initialization orders, making
this bug manifest on some platforms but not others.

Fix by replacing class-static std::string members with Meyers' Singleton
pattern (function-local statics), which C++11 guarantees are initialized
on first use in a thread-safe manner.

This fix benefits all architectures including x86_64, ARM64, and RISC-V.

Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
2026-05-29 15:29:04 +08:00
Sam Yuan f8eb9ec08e Nit enhance with const string (#2911)
* nit fix for using const

Signed-off-by: SamYuan1990 <yy19902439@126.com>

* as it just const string refactor

Signed-off-by: SamYuan1990 <yy19902439@126.com>

* fix up

Signed-off-by: SamYuan1990 <yy19902439@126.com>

* fix up

Signed-off-by: SamYuan1990 <yy19902439@126.com>

* fix up

Signed-off-by: SamYuan1990 <yy19902439@126.com>

* clean up

Signed-off-by: SamYuan1990 <yy19902439@126.com>

---------

Signed-off-by: SamYuan1990 <yy19902439@126.com>
2025-04-11 10:02:28 +08:00
jamesge c155614a40 remove exec bit from two source files 2019-10-07 23:12:54 -07:00
Weibing Wang 078051f9bf Update license header to Apache 2019-06-20 14:22:57 +08:00
helei fdc39b6b8c adjust unit test 2019-05-07 17:18:54 +08:00
helei a13730a4a1 add explicit key word 2019-05-07 17:06:24 +08:00