Skip to content

fix: disable libunwind in glog#383

Merged
longbinlai merged 10 commits into
alibaba:mainfrom
liulx20:main
May 22, 2026
Merged

fix: disable libunwind in glog#383
longbinlai merged 10 commits into
alibaba:mainfrom
liulx20:main

Conversation

@liulx20
Copy link
Copy Markdown
Collaborator

@liulx20 liulx20 commented May 20, 2026

This pull request updates the build_glog_as_third_party function in the cmake/BuildGlogAsThirdParty.cmake file to address a symbol conflict issue between libunwind and libgcc_s when building glog as a third-party dependency. The most significant change is the explicit disabling of libunwind support in glog to prevent runtime errors related to exception handling.

Dependency build configuration:

  • Added set(WITH_UNWIND OFF ...) to disable libunwind when building glog, preventing symbol conflicts with libgcc_s that could cause C++ exceptions to abort instead of being caught. This ensures reliable stack traces without introducing symbol resolution issues.

liulx20 added 2 commits May 20, 2026 20:25
Changed glog build configuration to create a shared library instead of a static library for proper dependency management.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the third-party glog build configuration to build glog as a shared library, aiming to improve runtime dependency behavior (notably around libunwind) and avoid leaking glog’s private dependencies into libneug.so.

Changes:

  • Switch glog from static to shared library build.
  • Add rationale comments explaining why shared glog is required for correct dependency/symbol resolution behavior.
Comments suppressed due to low confidence (1)

cmake/BuildGlogAsThirdParty.cmake:32

  • Changing BUILD_SHARED_LIBS in this helper can leak into subsequent add_subdirectory(...) calls and unintentionally flip other third-party builds to shared. Other helpers in this repo (e.g., protobuf) explicitly save/restore or unset BUILD_SHARED_LIBS after building the dependency; consider doing the same here to keep the change scoped to glog.
    set(BUILD_SHARED_LIBS ON)
    add_subdirectory(third_party/glog)
    include_directories(third_party/glog/src)
    include_directories(${CMAKE_CURRENT_BINARY_DIR}/third_party/glog/) # For generated headers
    set_target_properties(glog PROPERTIES DEBUG_POSTFIX "")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/BuildGlogAsThirdParty.cmake Outdated
@liulx20 liulx20 changed the title fix: Build glog as a shared library fix: force the use of static libunwind.a and its dependency liblzma.a when building glog May 21, 2026
@liulx20 liulx20 changed the title fix: force the use of static libunwind.a and its dependency liblzma.a when building glog fix: disable libunwind in glog May 21, 2026
liulx20 added 2 commits May 21, 2026 16:00
Removed unnecessary glog module directory settings and dependency on Unwind.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +23 to +29
# Disable libunwind in glog to prevent _Unwind_* symbol conflict with
# libgcc_s.so.1. When both libunwind.so.8 and libgcc_s.so.1 are loaded,
# the dynamic linker may resolve _Unwind_RaiseException to libunwind's
# version which cannot dispatch C++ exceptions, causing abort() instead
# of reaching catch blocks. With WITH_UNWIND=OFF, glog falls back to
# _Unwind_Backtrace from <unwind.h> (provided by libgcc_s) for stack
# traces in LOG(FATAL) / signal handlers — same quality, no conflict.
Copy link
Copy Markdown
Member

@zhanglei1949 zhanglei1949 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhanglei1949
Copy link
Copy Markdown
Member

From my point of view, it is ok to disable libunwind, since we don't really rely on the embedding stack trace printing from libunwind.

@longbinlai longbinlai merged commit db75398 into alibaba:main May 22, 2026
22 checks passed
@lnfjpt lnfjpt mentioned this pull request May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] try/catch fails to catch exceptions — process aborts due to libunwind/libgcc_s _Unwind_* symbol conflict

4 participants