Skip to content

mw/com[Bug]: fix infinite recursion in ProxyEvent move-assignment#399

Open
KrishaDeshkool wants to merge 1 commit intoeclipse-score:mainfrom
KrishaDeshkool:fix_move_bug
Open

mw/com[Bug]: fix infinite recursion in ProxyEvent move-assignment#399
KrishaDeshkool wants to merge 1 commit intoeclipse-score:mainfrom
KrishaDeshkool:fix_move_bug

Conversation

@KrishaDeshkool
Copy link
Copy Markdown
Contributor

No description provided.

@KrishaDeshkool KrishaDeshkool marked this pull request as ready for review May 8, 2026 14:56
@KrishaDeshkool KrishaDeshkool changed the title mw/com: fix infinite recursion in ProxyEvent move-assignment mw/com[Bug]: fix infinite recursion in ProxyEvent move-assignment May 8, 2026
Comment thread score/mw/com/impl/proxy_event.h Outdated
if (this != &other)
{
ProxyEvent::operator=(std::move(other));
ProxyEventBase::operator=(std::move(other));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ProxyEventBase::operator(std::move(static_cast<ProxyEventBase&&>(other)));

Comment thread score/mw/com/impl/proxy_event_test.cpp Outdated

using SampleType = std::uint16_t;

ProxyBase empty_proxy{std::make_unique<mock_binding::Proxy>(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not use the existing fixture?

Comment thread score/mw/com/impl/proxy_event_test.cpp Outdated

auto first_binding_ptr = std::make_unique<StrictMock<mock_binding::ProxyEvent<SampleType>>>();
auto second_binding_ptr = std::make_unique<StrictMock<mock_binding::ProxyEvent<SampleType>>>();
auto& first_binding = *first_binding_ptr;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We generally use ProxyEventFacade instead of this approach.

Comment thread score/mw/com/impl/proxy_event_test.cpp Outdated

// Then subsequent calls on the destination dispatch to the source's binding (proving the binding was transferred)
constexpr std::size_t max_sample_count{7U};
EXPECT_CALL(first_binding, GetSubscriptionState()).WillOnce(Return(SubscriptionState::kNotSubscribed));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

expectations should go above the when section

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this test pass without the change in proxy_event?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no, it crashes with back trace posted in another comment


TEST(ProxyEventTest, MoveAssignmentTransfersBindingFromSourceToDestination)
{
RecordProperty("Verifies", "SCR-5897869"); // SWS_CM_00135
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What requirement are you linking here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it is a copy paste from the one above which checked this "IsMovable"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is actually happening in the old code? I can't imagine that there was actually infinite recursion because we would have seen it when moving a proxy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you can run this without changing the move op

gdb --batch --ex 'run --gtest_filter=ProxyEventTest.MoveAssignmentTransfersBindingFromSourceToDestination' --ex 'bt 10' bazel-bin/score/mw/com/impl/proxy_event_test
then you will see this

Program received signal SIGSEGV, Segmentation fault.
0x0000555555604d32 in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#0 0x0000555555604d32 in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#1 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#2 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#3 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#4 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#5 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#6 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#7 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#8 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
#9 0x0000555555604d5f in score::mw::com::impl::ProxyEvent::operator=(score::mw::com::impl::ProxyEvent&&) & ()
q551424@clid2082740:~/score/communication (fix_move_bug)$ gdb --batch --ex 'run --gtest_filter=ProxyEventTest.MoveAssignmentTransfersBindingFromSourceToDestination' --ex 'bt 10' bazel-bin/score/mw/com/impl/proxy_event_test

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.

2 participants