Skip to content

Commit

Permalink
Make lsan happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo committed Apr 12, 2019
1 parent e8d1eef commit 395471c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ jobs:
- third_party/depot_tools/gn gen target/debug
- export ASAN_OPTIONS=detect_leaks=1
- ./tools/build.py test_cc
- ./target/debug/test_cc
- ./target/debug/test_cc --expose-gc

5 changes: 5 additions & 0 deletions core/libdeno/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ Deno* deno_new(deno_config config) {
deno::InitializeContext(isolate, context);
}
d->context_.Reset(isolate, context);

d->gc_observer_private_symbol_.Reset(
isolate,
v8::Private::New(isolate, v8::String::NewFromUtf8(
isolate, "deno:gc_observer:symbol")));
}

return reinterpret_cast<Deno*>(d);
Expand Down
5 changes: 5 additions & 0 deletions core/libdeno/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,17 @@ void SetGCObserver(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate::Scope isolate_scope(isolate);
v8::EscapableHandleScope handle_scope(isolate);

DenoIsolate* d = DenoIsolate::FromIsolate(isolate);
auto context = d->context_.Get(isolate);
auto obj = args[0].As<v8::Object>();
auto callback = args[1].As<v8::Function>();

auto observer = new GCObserver();
observer->Register(isolate, obj);
observer->SetCallback(isolate, callback);
// Make LSAN happy
obj->SetPrivate(context, d->gc_observer_private_symbol_.Get(isolate),
v8::External::New(isolate, observer));

handle_scope.Escape(obj);
args.GetReturnValue().Set(obj);
Expand Down
1 change: 1 addition & 0 deletions core/libdeno/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class DenoIsolate {
deno_resolve_cb resolve_cb_;

v8::Persistent<v8::Context> context_;
v8::Persistent<v8::Private> gc_observer_private_symbol_;
std::map<size_t, v8::Persistent<v8::Value>> zero_copy_map_;
std::map<int, v8::Persistent<v8::Value>> pending_promise_map_;
std::string last_exception_;
Expand Down

0 comments on commit 395471c

Please sign in to comment.