-
Notifications
You must be signed in to change notification settings - Fork 39
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
Incorrect destructor order call #123
Comments
Thank you for the report. I'll try to see what is possible for kangaru 4. Changing the destruction is a breaking change and cannot happen without an explicit compile time switch or a new major version. |
The workaround to handle such cases until a fix is implemented might not be ideal but is to use |
I can confirm this only happens with autowire services. This is due to a two step initialization. Before autowire, all dependencies were created before insertion so it didn't matter that we inserted the service in the instance vector before constructing the class. It was indeed a bug that cause UB if using particular service types so I won't consider this a breaking change. |
Fixed by e941e69. You can use master if you need the fix now, but I will release a version with the fix, probably 4.3.2. The order of destruction will be the one you expect if you use |
Describe the bug
When attempting to access the resource
X
that we know depends onY
, it should be valid to access theY
resource duringX
's destructor, but from my use cases, it's solely dependant on order of instantiation of service, orKGR_KANGARU_REVERSE_DESTRUCTION
which just reverse release the resources.To Reproduce
1- Create the
main.cpp
with the following content:Expected behavior
The program should output the following regardless of
KANGARU_REVERSE_DESTRUCTION
valueWith
KANGARU_REVERSE_DESTRUCTION
enabledWithout
KANGARU_REVERSE_DESTRUCTION
Desktop (please complete the following information):
Additional context
This is an important issue that mustn't be overlooked as it violates C++ order of destructors.
The text was updated successfully, but these errors were encountered: