Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ endif()
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG has_windbg.cpp "" "dbgeng;ole32" "")
stacktrace_check(BOOST_STACKTRACE_HAS_WINDBG_CACHED has_windbg_cached.cpp "${CMAKE_CURRENT_SOURCE_DIR}/../config/include" "dbgeng;ole32" "")

stacktrace_check(BOOST_STACKTRACE_USES_LIBSTDCPP uses_libstdc++.cpp "" "" "")

set(_default_from_exception ON)
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|amd64|i386|i686|x86")
if ((NOT CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|amd64|i386|i686|x86") AND (NOT BOOST_STACKTRACE_USES_LIBSTDCPP))
set(_default_from_exception OFF)
endif()

Expand Down
10 changes: 8 additions & 2 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ explicit WinDbg ;
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
explicit WinDbgCached ;

mp-run-simple uses_libstdc++.cpp : : : : UsesLibStdCpp ;
explicit UsesLibStdCpp ;

rule build-stacktrace-noop ( props * )
{
local enabled = [ property.select <boost.stacktrace.noop> : $(props) ] ;
Expand Down Expand Up @@ -252,8 +255,11 @@ rule build-stacktrace-from-exception ( props * )
local arch = [ property.select <architecture> : $(props) ] ;
if $(arch) && ( $(arch:G=) != x86 )
{
configure.log-library-search-result "boost.stacktrace.from_exception" : "no" ;
return <build>no ;
if ! [ configure.builds UsesLibStdCpp : $(props) : "boost.stacktrace.from_exception" ]
{
configure.log-library-search-result "boost.stacktrace.from_exception" : "no" ;
return <build>no ;
}
}
configure.log-library-search-result "boost.stacktrace.from_exception" : "yes" ;
}
Expand Down
15 changes: 15 additions & 0 deletions build/uses_libstdc++.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright Romain Geissler, 2025.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#include <cstdlib>

int main() {
#ifdef __GLIBCXX__
return 0;
#else
#error "The C++ runtime library isn't libstdc++"
#endif
}
8 changes: 8 additions & 0 deletions src/from_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ BOOST_SYMBOL_EXPORT void assert_no_pending_traces() noexcept {
#include <mutex>
#include <unordered_map>

// If we use libstdc++, we know the current implementation works and doesn't leak.
// It's not the case of libc++ where we know there might be leaks and thus we try
// to ensure the user is aware about it and only build this when
// BOOST_STACKTRACE_LIBCXX_RUNTIME_MAY_CAUSE_MEMORY_LEAK is defined.
#ifndef __GLIBCXX__

#ifndef BOOST_STACKTRACE_LIBCXX_RUNTIME_MAY_CAUSE_MEMORY_LEAK

#ifdef BOOST_HAS_THREADS
Expand All @@ -185,6 +191,8 @@ BOOST_SYMBOL_EXPORT void assert_no_pending_traces() noexcept {

#endif

#endif

namespace {

constexpr std::size_t kStacktraceDumpSize = 4096;
Expand Down