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

Possible resource leak in ucontext implementation #99

Closed
prograholic opened this issue Feb 21, 2019 · 5 comments

Comments

@prograholic
Copy link

commented Feb 21, 2019

Hi,

I see some strange pattern in continuation_ucontext.hpp:

Line 295: we construct new object using placement new operator https://github.com/boostorg/context/blob/develop/include/boost/context/continuation_ucontext.hpp#L295
Line 302: we throw exception https://github.com/boostorg/context/blob/develop/include/boost/context/continuation_ucontext.hpp#L302

Same pattern we can find in function create_context2

Do we need to destroy our object before throwing exception?

@olk

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

you are right - before throw a salloc.allocate(sctx) is missing
ty

@2underscores-vic

This comment has been minimized.

Copy link

commented Feb 22, 2019

record->~capture_t();

?

@olk

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

capture_record/fiber_capture_record do not have member variables or execute special code in the dtor

@2underscores-vic

This comment has been minimized.

Copy link

commented Feb 22, 2019

Yes. But destructor is not trivial (and virtual)! I know that it 'just works' but still. Wouldn't it be better to be C++-conformant here?

olk added a commit that referenced this issue Feb 22, 2019
@olk

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

probably yes - fixed
ty

@olk olk closed this Feb 22, 2019

owt5008137 added a commit to owt5008137/libcopp that referenced this issue Aug 20, 2019
Move changelog out of README.md.Merge boost.context 1.71.0
boost.context: https://www.boost.org/users/history/version_1_71_0.html
  Add support for RISC-V LP64D
  [#72](boostorg/context#72): Fix ABI violation on ppc64 ELFv2
  [#99](boostorg/context#99): cleanup of stack if creating ucontext fails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.