eclipse-iceoryx / eclipse-iceoryx/iceoryx

Undefined behavior in all classes with `getMembers` method

Open
#1,001 1 comment 0 reactions 0 assignees View on GitHub
refactoring
Dominant language
C++
Stars
2.2k
Forks
492
Avg merge
18h 57m
Merged PRs (30d)
1

Description

## Required information

Nearly all classes with the method `getMembers()` have undefined behavior after move since the move constructor and assignment operator have default specifiers which do not invalidate the underlying data pointer.

## (Maybe incomplete list) of all affected classes
* InterfacePort
* ServerPortUser
* PublisherPortUser
* PublisherPortRoudi
* ServerPortRoudi
* ApplicationPort
* SubscriberPortUser
* ClientPortUser
* ClientPortRoudi
* BasePort
* ChunkQueuePopper
* ChunkSender
* ChunkQueuePusher
* ChunkReceiver
* ConditionListener
* ConditionNotifier
* ChunkDistributor

## Solution
1. For every class an explicit move constructor and move assignment operator has to be implemented which invalidates the pointer to the members.
But please pay attention to call the parent move constructor/assignment operator first when there is inheritance involved!
```cpp
Parent::operator=(std::move(*this));
```

2. `getMembers` must return a reference/const reference to the underlying members since the members should be never `nullptr`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the listed classes and their getMembers() methods, then inspect each move constructor and move assignment operator, especially where inheritance is involved. Done means moved-from objects no longer expose invalid member pointers and getMembers() returns the underlying members by reference; verify the affected classes with the project's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.