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

Shared Scope does not destruct singletons in the correct order. #545

Open
t-moe opened this issue Feb 7, 2023 · 0 comments
Open

Shared Scope does not destruct singletons in the correct order. #545

t-moe opened this issue Feb 7, 2023 · 0 comments

Comments

@t-moe
Copy link

t-moe commented Feb 7, 2023

Expected Behavior

The shared scope (boost::di::extension::shared_config) destructs the singletons in the reverse order they were created.

Actual Behavior

The singletons are destructed in the order of their type_index. See https://github.com/boost-ext/di/blob/cpp14/extension/include/boost/di/extension/scopes/shared.hpp#L113-L119

Steps to Reproduce the Problem

  1. Create a injector and bind a few classes that take singletons (e.g. T&) in their constructor
  2. Use the injector to create an object
  3. Store the injector as a class member. (See also Shared scope behaves unexpectedly when the injector is a class member #527 )
  4. Run some code using the correctly created object and the singletons that were injected into it
  5. Delete the injector
  6. The singletons will be deleted in the wrong order

Specifications

  • Version: Code from github cpp14 branch
  • Platform: Linux / Windows
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

No branches or pull requests

1 participant