Skip to content

Using future<>::detach() is a possible memory leak  #134

@sean-parent

Description

@sean-parent
{
auto p = package<int()>(immediate_executor, []{ return 42; });
p.second.then([a = annotate()](int x){ std::cout << x << '\n'; }).detach();
}

outputs:

annotate ctor
annotate move-ctor
annotate move-ctor
annotate move-ctor
annotate move-ctor
annotate dtor
annotate dtor
annotate dtor
annotate dtor

Notice we are one dtor short... detach() creates a retain cycle - this needs to be broken in the event of a broken promise exception (or any exception).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions