This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 29b23731c fix(command): fix static initialization crash on 
Kunpeng/Kylin platform (#3416)
29b23731c is described below

commit 29b23731ca9096f60be82bbc72d8c1c45be8d021
Author: sryan yuan <[email protected]>
AuthorDate: Thu Apr 9 15:20:44 2026 +0800

    fix(command): fix static initialization crash on Kunpeng/Kylin platform 
(#3416)
    
    ## Problem:
    
    We've identified a critical startup crash specific to Kunpeng processors
    (aarch64) running Kylin OS v10 with GCC 12.5.0. The root cause is a
    static initialization order issue where:
    
    * Static command registration objects (e.g., RegisterToCommandTable in
    command files) initialize before CommandTable's static containers
    * This leads to accessing uninitialized containers during startup:
    ```cpp
    CommandTable::commands[attr.name] = ...;  // ❌ Accesses uninitialized map
    ```
    
    * On Kunpeng/Kylin/GCC12.5, this consistently manifests as:
      * Segmentation faults during static initialization
      * 100% failure rate in cold starts
    
    ## Solution:
    
    Implement the "construct on first use" pattern to guarantee safe
    initialization.
    
    ## Key Changes:
    
    * Converted all static members in CommandTable to accessor functions
    * Updated all references to use function-call
    * Maintained identical public interface while fixing initialization
    guarantees
    
    Co-authored-by: Twice <[email protected]>
---
 CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6c5343dd..a378db524 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -298,6 +298,12 @@ else()
     target_compile_definitions(kvrocks_objs PUBLIC METADATA_ENCODING_VERSION=0)
 endif()
 
+# disable LTO on ARM due to toolchain stability issues
+string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER)
+if(CMAKE_SYSTEM_PROCESSOR_LOWER MATCHES "^(aarch64|arm64|arm)")
+    set(ENABLE_LTO OFF)
+endif()
+
 # disable LTO on GCC <= 9 due to an ICE
 if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION 
VERSION_LESS 10))
     set(ENABLE_LTO OFF)

Reply via email to