Skip to content

Commit

Permalink
fixes segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Sep 6, 2020
1 parent abe1908 commit 8cc590f
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ impl<'a> plugin_api::Interface for PluginInterface<'a> {
self.state.register_op(
name,
move |state: Rc<State>, mut zero_copy: BufVec| {
// This is a hack that ensures that dispatch_op_fn is dropped first to
// prevent segfaults.
let _ = &dispatch_op_fn;
let _ = &plugin_lib;
let mut interface = PluginInterface::new(&state, &plugin_lib);
let op = dispatch_op_fn(&mut interface, &mut zero_copy);
match op {
Expand Down
9 changes: 0 additions & 9 deletions core/core_isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,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 8cc590f

Please sign in to comment.