You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src: track cppgc wrappers with CppgcWrapperList in Environment
This allows us to perform cleanups of cppgc wrappers that rely
on a living Environment during Environment shutdown. Otherwise
the cleanup may happen during object destruction, which can
be triggered by GC after Enivronment shutdown, leading to invalid
access to Environment.
The general pattern for this type of non-trivial destruction is
designed to be:
```
class MyWrap final : CPPGC_MIXIN(MyWrap) {
public:
~MyWrap() { this->Clean(); }
void CleanEnvResource(Environment* env) override {
// Do cleanup that relies on a living Environemnt. This would be
// called by CppgcMixin::Clean() first during Environment shutdown,
// while the Environment is still alive. If the destructor calls
// Clean() again later during garbage collection that happens after
// Environment shutdown, CleanEnvResource() would be skipped, preventing
// invalid access to the Environment.
}
}
```
In addition, this allows us to trace external memory held by the wrappers
in the heap snapshots if we add synthethic edges between the wrappers
and other nodes in the embdder graph callback, or to perform snapshot
serialization for them.
0 commit comments