Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resource leak caused by move ctor/assignment #542

Closed
18 tasks done
elfenpiff opened this issue Feb 4, 2021 · 1 comment · Fixed by #550, #553, #554, #557 or #565
Closed
18 tasks done

Fix resource leak caused by move ctor/assignment #542

elfenpiff opened this issue Feb 4, 2021 · 1 comment · Fixed by #550, #553, #554, #557 or #565
Assignees
Labels
bug Something isn't working
Milestone

Comments

@elfenpiff
Copy link
Contributor

elfenpiff commented Feb 4, 2021

Required information

All versions

Observed result or behaviour:
The classes:

are not cleaning up the resources while performing move. This could lead to a resource leak when for instance the following pseudo code is executed.

SharedMemory mySharedMemory; // create a shared memory file A
SharedMemory anotherSharedMemory; // create a shared memory file B

mySharedMemory = std::move(anotherSharedMemory); // mySharedMemory takes ownership of B without releasing A

// at this point the shared memory file A is leaked

Classes with correct move resource handling:

  • Semaphore
  • MessageQueue
  • optional
  • variant

Handle undefined state:

  • optional
  • expected

creation pattern:

  • shared_memory
  • shared_memory_object
  • memory_map

Fix incorrect move CTor/assigned in all classes derived from DesignPattern::Creation
According to: https://isocpp.org/wiki/faq/assignment-operators every move ctor/assignment operator has to be implemented like

Derived& Derived::operator= (Derived&& d)
{
  // self-assignment is not allowed in move assignment
  Base::operator= (std::move(d));
  // Do the rest of your assignment operator here...
  return *this;
}
  • shared_memory
  • shared_memory_object
  • memory_map
  • semaphore
  • message_queue
  • unix_domain_socket
  • Write a detailed documentation how to use the creation pattern correctly - especially the assignment operator part!

Fix sighandler

  • Write mini sigaction abstraction and put it into utils to remove the 5 lines of code.
  • Use posix::SignalHandler everywhere

Details

  • Consider this discussion
@elfenpiff elfenpiff self-assigned this Feb 4, 2021
@elfenpiff elfenpiff added this to the Prio 1 milestone Feb 4, 2021
@elfenpiff elfenpiff added this to To do in v1.0 via automation Feb 4, 2021
@elfenpiff elfenpiff added the bug Something isn't working label Feb 4, 2021
@elfenpiff
Copy link
Contributor Author

@sschnitzer Thank you for finding this!

@elfenpiff elfenpiff added this to To do in Sprints via automation Feb 4, 2021
@elfenpiff elfenpiff moved this from To do to Current in Sprints Feb 4, 2021
mossmaurice added a commit to ApexAI/iceoryx that referenced this issue Feb 9, 2021
…ks in UnixDomainSocket

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
@mossmaurice mossmaurice linked a pull request Feb 10, 2021 that will close this issue
19 tasks
mossmaurice added a commit to ApexAI/iceoryx that referenced this issue Feb 10, 2021
… for sane move semantics

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
… when being moved

Signed-off-by: Christian Eltzschig <me@elchris.org>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
…tor callback when being moved

Signed-off-by: Christian Eltzschig <me@elchris.org>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
…rapper

Signed-off-by: Christian Eltzschig <me@elchris.org>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
@mossmaurice mossmaurice linked a pull request Feb 11, 2021 that will close this issue
19 tasks
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
mossmaurice added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
mossmaurice added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
… tests to test the behavior more accurate

Signed-off-by: Christian Eltzschig <me@elchris.org>
elfenpiff added a commit to ApexAI/iceoryx that referenced this issue Feb 11, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
v1.0 automation moved this from To do to Done Feb 12, 2021
Sprints automation moved this from Current to Done Feb 12, 2021
elfenpiff added a commit that referenced this issue Feb 26, 2021
…-docu

iox-#542 creation pattern detailed doxygen docu
@elBoberido elBoberido reopened this Feb 26, 2021
Sprints automation moved this from Done to In progress Feb 26, 2021
v1.0 automation moved this from Done to In progress Feb 26, 2021
v1.0 automation moved this from In progress to Done Feb 26, 2021
Sprints automation moved this from In progress to Done Feb 26, 2021
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…wrapper' of github.com:ApexAI/iceoryx into iox-eclipse-iceoryx#542-use-creation-pattern-for-posix-wrapper
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…ion-pattern-for-posix-wrapper

Iox eclipse-iceoryx#542 use creation pattern for posix wrapper
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…terminate usage

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…o there

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…n tests

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…load for get_error()

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…zschig, introducing INDEX for variant in expected, updating copyright and reverting or_else behaviour

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
… type traits and move impl to inl

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
Signed-off-by: Christian Eltzschig <me@elchris.org>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
… state behaviour

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…isInitialized and m_errorValue

Signed-off-by: Christian Eltzschig <me@elchris.org>
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…semantic-in-expected

Iox eclipse-iceoryx#542 Invalidate `rhs` if an `expected` is moved
marthtz pushed a commit to boschglobal/iceoryx that referenced this issue May 12, 2021
…pattern-doxygen-docu

iox-eclipse-iceoryx#542 creation pattern detailed doxygen docu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment