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

[BUGFIX lts] Ensure instantiation cannot happen after destruction. #18717

Merged
merged 1 commit into from
Jan 31, 2020

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Jan 31, 2020

This changes a bit about how destruction occurs and is enforced. Without these changes, it is possible to introduce memory leaks in FastBoot in a few (somewhat specialized) scenarios. Some examples:

  • if you were to call owner.lookup sometime after the owner itself was destroyed. During development and tests we prevent this (by way of an assertion), but in production we happily recreate the instances (without marking them as isDestroying) and never destroy them
  • if you were to call owner.lookup during destruction (e.g. in another services willDestroy) we would emit no warning / assertion even in development mode, and we would never destroy the instances created

In order to prevent these situations, this commit introduces these changes:

  1. ensure that looking things up from the container during destruction emits a deprecation
  2. ensure that looking things up from the container after destruction throws an error (not an assertion)
  3. ensure that any objects that are instantiated during container destruction (even though deprecated) will themselves be destroyed

This changes a bit about how destruction occurs and is enforced. Without
these changes, it is possible to introduce memory leaks in FastBoot in
a few (somewhat specialized) scenarios. Some examples:

* if you were to call `owner.lookup` sometime after the owner itself was
  destroyed.  During development and tests we prevent this (by way of an
  assertion), but in production we happily recreate the instances
  (without marking them as `isDestroying`) and never destroy them
* if you were to call `owner.lookup` _during_ destruction (e.g. in
  another services `willDestroy`) we would emit no warning / assertion
  even in development mode, and we would never destroy the instances
  created

In order to prevent these situations, this commit introduces these
changes:

1. ensure that looking things up from the container _during_
   destruction emits a deprecation
2. ensure that looking things up from the container _after_ destruction
   throws an error (**not** an assertion)
3. ensure that any objects that _are_ instantiated during container
   destruction (even though deprecated) will themselves be destroyed
@rwjblue rwjblue merged commit 522c2d0 into emberjs:master Jan 31, 2020
@rwjblue rwjblue deleted the container-cleanup-race-oh-my branch January 31, 2020 02:35
chancancode added a commit that referenced this pull request Feb 7, 2020
We agreed that it was important to fix the error cases in #18717, but
while the work may be unnecessary, there isn't necessarily any
"correctness" issues with looking up things during destruction. Using
a deprecation to warn about potentially "unnecessary" work is a bit
heavy-handed, and at minimum requires some more continued discussions,
so reverting that part of the PR for now (while keeping the errors in
tact).
chancancode added a commit that referenced this pull request Feb 8, 2020
We agreed that it was important to fix the error cases in #18717, but
while the work may be unnecessary, there isn't necessarily any
"correctness" issues with looking up things during destruction. Using
a deprecation to warn about potentially "unnecessary" work is a bit
heavy-handed, and at minimum requires some more continued discussions,
so reverting that part of the PR for now (while keeping the errors in
tact).

(cherry picked from commit b853324)
chancancode added a commit that referenced this pull request Feb 8, 2020
We agreed that it was important to fix the error cases in #18717, but
while the work may be unnecessary, there isn't necessarily any
"correctness" issues with looking up things during destruction. Using
a deprecation to warn about potentially "unnecessary" work is a bit
heavy-handed, and at minimum requires some more continued discussions,
so reverting that part of the PR for now (while keeping the errors in
tact).

(cherry picked from commit b853324)
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.

3 participants