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

CBL-5660 : Fix a released query context may be used in observer callback #3285

Open
wants to merge 2 commits into
base: release/3.2
Choose a base branch
from

Conversation

pasin
Copy link
Contributor

@pasin pasin commented May 9, 2024

  • Ported the fix directly from release/3.1 branch.

  • Implemented CBLContextManager class for retaining and mapping the object with its pointer value which can be used as the context for LiteCore's callbacks (e.g. use when creating c4queryobserver objects). The implementation simply stores the object in a map by using its memory address as the key and returns the memory address as the pointer value.

  • Updated CBLQueryObserver to use CBLContextManager to make sure that the released query context can be detected and not be used. When using the query context, the query context is retained.

  • Added a test for CBSE-16662 which is related to this issue and two tests to check that there are no notification received without crash (CBL-5660) after removing the token.

  • Added an internal debug build only C4QueryObserverCallbackDelayInterval config for testing the fix.

* Directly ported the fix from release/3.1 branch.

* Implemented CBLContextManager class for retaining and mapping the object with its pointer value which can be used as  the context for LiteCore's callbacks (e.g. use when creating c4queryobserver objects). The implementation simply stores the object in a map by using its memory address as the key and returns the memory address as the pointer value.

* Updated CBLQueryObserver to use CBLContextManager to make sure that the released query context can be detected and not be used. When using the query context, the query context is retained.

* Added a test for CBSE-16662 which is related to this issue and two tests to check that there are no notification received without crash (CBL-5660) after removing the token.

* Added an internal debug build only C4QueryObserverCallbackDelayInterval config for testing the fix.
@pasin
Copy link
Contributor Author

pasin commented May 9, 2024

After all, need a new LiteCore that includes couchbase/couchbase-lite-core#2025.

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

Successfully merging this pull request may close these issues.

None yet

2 participants