Skip to content

Commit

Permalink
fixes segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Sep 4, 2020
1 parent 41ae65b commit 024f636
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 4 additions & 0 deletions cli/ops/plugin.rs
Expand Up @@ -109,6 +109,10 @@ impl<'a> plugin_api::Interface for PluginInterface<'a> {
self.isolate_state.op_registry.register(
name,
move |isolate_state, zero_copy| {
// This is a hack that ensures that dispatch_op_fn is dropped first to
// prevent segfaults.
dispatch_op_fn;
plugin_lib;
let mut interface = PluginInterface::new(isolate_state, &plugin_lib);
let op = dispatch_op_fn(&mut interface, zero_copy);
match op {
Expand Down
9 changes: 0 additions & 9 deletions core/core_isolate.rs
Expand Up @@ -147,15 +147,6 @@ impl DerefMut for CoreIsolate {
}
}

impl Drop for CoreIsolateState {
fn drop(&mut self) {
// TODO(afinch7) this is a temporary fix for a segfault that occurus when
// dropping plugin ops. I know that the plugin Rc<Library> value gets dropped
// early for some reason, but still not quite sure why.
drop(std::mem::take(&mut self.op_registry));
}
}

impl Drop for CoreIsolate {
fn drop(&mut self) {
if let Some(creator) = self.snapshot_creator.take() {
Expand Down

0 comments on commit 024f636

Please sign in to comment.