Skip to content

Commit 462500e

Browse files
committed
Workaround crash with dtraced shared libraries under GCC 3.4.6 on 32 bit Solaris.
Crash happens in dlopen() code when trying to load the library. Crash does not happen when library is not DTrace instrumented . Additionally, crash does not happen with default Solaris 10 GCC 3.4.3 and it does not happen if main executable is instrumented. So , just check for this specific situation (32 bit, GCC3.4.6 , Solaris) and disable Dtrace in shared libraries. We have only single plugin so far that is instrumented (ha_example)
1 parent 342c5c2 commit 462500e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

cmake/dtrace.cmake

+23-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,29 @@ IF(ENABLE_DTRACE)
7272
)
7373
ENDIF()
7474

75+
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
76+
AND CMAKE_SIZEOF_VOID_P EQUAL 4)
77+
IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
78+
EXECUTE_PROCESS(
79+
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version
80+
OUTPUT_VARIABLE out)
81+
IF(out MATCHES "3.4.6")
82+
# This gcc causes crashes in dlopen() for dtraced shared libs,
83+
# while standard shipped with Solaris10 3.4.3 is ok
84+
SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
85+
ELSE()
86+
SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
87+
ENDIF()
88+
ENDIF()
89+
ENDIF()
7590

76-
MACRO(DTRACE_INSTRUMENT target)
91+
FUNCTION(DTRACE_INSTRUMENT target)
92+
IF(BUGGY_GCC_NO_DTRACE_MODULES)
93+
GET_TARGET_PROPERTY(target_type ${target} TYPE)
94+
IF(target_type MATCHES "MODULE_LIBRARY")
95+
RETURN()
96+
ENDIF()
97+
ENDIF()
7798
IF(ENABLE_DTRACE)
7899
ADD_DEPENDENCIES(${target} gen_dtrace_header)
79100

@@ -119,7 +140,7 @@ MACRO(DTRACE_INSTRUMENT target)
119140
ENDIF()
120141
ENDIF()
121142
ENDIF()
122-
ENDMACRO()
143+
ENDFUNCTION()
123144

124145

125146
# Ugly workaround for Solaris' DTrace inability to use probes

0 commit comments

Comments
 (0)