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

group_by with not completed observable issue #403

Open
diorcety opened this issue Sep 19, 2017 · 8 comments
Open

group_by with not completed observable issue #403

diorcety opened this issue Sep 19, 2017 · 8 comments
Labels

Comments

@diorcety
Copy link
Contributor

I found an potential issue with flat_map operation when source the is a scoped observable using a factory holding a shared pointer.
In this case my shared pointer is not released after the last unsubscribe of the observable returned by flat_map.
I didn't succeed to produce a minimal example that trigger this issue, but a quick and dirty hack seems to solve the issue:
if I "reset" the state_type source (which is manly not used):
this->source = source_type();
my smart pointer is released when I unsubscribe.
Maybe this is an issue on my side, but I go many times through my code, I don't see the issue

@kirkshoop
Copy link
Member

Hard to say without specific repro, but I would assume that something has stored the flat_map. the source must stay valid while the flat_map observable exists because it has to assume that subscribe might be called again.

@diorcety
Copy link
Contributor Author

The source is still valid in the initial variable. I will try harder to create minimal example

@diorcety
Copy link
Contributor Author

@diorcety
Copy link
Contributor Author

Commented on_completed:

Hello, World!
Abcd
Value: 0
Value: 20
Unsubscribe
End of World!

Uncommented

Hello, World!
Abcd
Value: 0
Value: 20
~Abcd
Unsubscribe
End of World!

@diorcety
Copy link
Contributor Author

The issue is certainly in the group_by not the flat_map

@diorcety diorcety changed the title flat_map with scoped group_by with not completed observable issue Sep 20, 2017
@diorcety
Copy link
Contributor Author

diorcety commented Sep 20, 2017

In both case at the unsubscribe, the hook (held by the lambda) should be released. Because there is no link to the observable anymore

@kirkshoop
Copy link
Member

this is probably a bug in the lifetime - possibly introduced by (8065a79#diff-9430ecceb5eeb688548de212b7fd57be)

Pure speculation, but it may be similar to the bug in window_toggle fixed here (b41b15f)

I will add this to the backlog - thank you for the report!

as a workaround until this bug is fixed, adding a take_until before the group_by where the trigger parameter was a subject whose on_next was called each time the cancellation was desired should complete the stream cleanly.

@kirkshoop kirkshoop added the bug label Sep 22, 2017
@diorcety
Copy link
Contributor Author

I was on a old version, seems to be solved in the master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants