From 34c20d191f9ef5a2a75b9a1cccaee4c44e722d3c Mon Sep 17 00:00:00 2001 From: afinch7 Date: Fri, 4 Sep 2020 10:40:28 -0400 Subject: [PATCH] fixes segfault --- cli/ops/plugin.rs | 4 ++++ core/core_isolate.rs | 9 --------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cli/ops/plugin.rs b/cli/ops/plugin.rs index f7c4c667c6c5f0..accf458a88b91a 100644 --- a/cli/ops/plugin.rs +++ b/cli/ops/plugin.rs @@ -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. + let _ = &dispatch_op_fn; + let _ = &plugin_lib; let mut interface = PluginInterface::new(isolate_state, &plugin_lib); let op = dispatch_op_fn(&mut interface, zero_copy); match op { diff --git a/core/core_isolate.rs b/core/core_isolate.rs index 98345cd251b90d..a60ce6a82d1908 100644 --- a/core/core_isolate.rs +++ b/core/core_isolate.rs @@ -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 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() {