Skip to content
Closed
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
8 changes: 8 additions & 0 deletions source/test/bulkdata/profileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ TEST_F(ProfileTest, ClearMarkerComponentMapShouldRemoveEntries) {

EXPECT_EQ(Vector_Size(eventComponentList), 0);
EXPECT_EQ(destroyT2MarkerComponentMap(), T2ERROR_SUCCESS);
// Reinitialize for subsequent tests that depend on marker component map
EXPECT_CALL(*g_vectorMock, Vector_Create(_))
.Times(::testing::AtMost(1))
.WillRepeatedly(Return(T2ERROR_SUCCESS));
EXPECT_CALL(*g_vectorMock, Vector_Destroy(_, _))
.Times(::testing::AtMost(1))
.WillRepeatedly(Return(T2ERROR_SUCCESS));
EXPECT_EQ(initT2MarkerComponentMap(), T2ERROR_SUCCESS);
Comment on lines 509 to +517
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

Calling initT2MarkerComponentMap() here can double-initialize internal static mutexes (e.g., t2CompListMutex is pthread_mutex_init()'d in initT2MarkerComponentMap() but is never pthread_mutex_destroy()'d in destroyT2MarkerComponentMap()). This is undefined behavior and can lead to flaky crashes or EBUSY failures. A safer test-only fix would be to avoid destroyT2MarkerComponentMap() in this test (it’s not needed to validate clear semantics), or move init/destroy into a suite-level SetUpTestSuite/TearDownTestSuite so init runs once and destroy runs once at the end.

Suggested change
EXPECT_EQ(destroyT2MarkerComponentMap(), T2ERROR_SUCCESS);
// Reinitialize for subsequent tests that depend on marker component map
EXPECT_CALL(*g_vectorMock, Vector_Create(_))
.Times(::testing::AtMost(1))
.WillRepeatedly(Return(T2ERROR_SUCCESS));
EXPECT_CALL(*g_vectorMock, Vector_Destroy(_, _))
.Times(::testing::AtMost(1))
.WillRepeatedly(Return(T2ERROR_SUCCESS));
EXPECT_EQ(initT2MarkerComponentMap(), T2ERROR_SUCCESS);

Copilot uses AI. Check for mistakes.
}

#endif
Expand Down
Loading