-
Notifications
You must be signed in to change notification settings - Fork 417
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.13' into backport-10962-to-2.13
- Loading branch information
Showing
7 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ddtrace/internal/datadog/profiling/stack_v2/test/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG release-1.11.0) | ||
set(gtest_force_shared_crt | ||
ON | ||
CACHE BOOL "" FORCE) | ||
set(INSTALL_GTEST | ||
OFF | ||
CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
include(GoogleTest) | ||
include(AnalysisFunc) | ||
|
||
function(dd_wrapper_add_test name) | ||
add_executable(${name} ${ARGN}) | ||
target_include_directories(${name} PRIVATE ../include) | ||
target_link_libraries(${name} PRIVATE gmock gtest_main _stack_v2) | ||
add_ddup_config(${name}) | ||
|
||
gtest_discover_tests(${name}) | ||
endfunction() | ||
|
||
# Add the tests | ||
dd_wrapper_add_test(thread_span_links thread_span_links.cpp) |
48 changes: 48 additions & 0 deletions
48
ddtrace/internal/datadog/profiling/stack_v2/test/thread_span_links.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <string> | ||
#include <thread> | ||
|
||
#include "thread_span_links.hpp" | ||
|
||
static void | ||
get() | ||
{ | ||
for (int i = 0; i < 100; i++) { | ||
std::string span_type; | ||
for (int j = 0; j < i; j++) { | ||
span_type.append("a"); | ||
} | ||
Datadog::ThreadSpanLinks::get_instance().link_span(42, 1, 2, span_type); | ||
} | ||
} | ||
|
||
static std::string | ||
set() | ||
{ | ||
std::string s; | ||
for (int i = 0; i < 100; i++) { | ||
auto thing = Datadog::ThreadSpanLinks::get_instance().get_active_span_from_thread_id(42); | ||
if (!thing) { | ||
continue; | ||
} | ||
s = thing->span_type; | ||
} | ||
return s; | ||
} | ||
|
||
TEST(ThreadSpanLinksConcurrency, GetSetRace) | ||
{ | ||
std::thread t1(get); | ||
std::thread t2(set); | ||
t1.join(); | ||
t2.join(); | ||
} | ||
|
||
int | ||
main(int argc, char** argv) | ||
{ | ||
::testing::InitGoogleTest(&argc, argv); | ||
(void)(::testing::GTEST_FLAG(death_test_style) = "threadsafe"); | ||
return RUN_ALL_TESTS(); | ||
} |
5 changes: 5 additions & 0 deletions
5
releasenotes/notes/profiling-fix-data-race-segfault-b14f59c06c6bf9ed.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
fixes: | ||
- | | ||
profiling: fix a data race where span information associated with a thread | ||
was read and updated concurrently, leading to segfaults |