From 995e1e3ee7d1b7048284b6486c818c4ede01b3f9 Mon Sep 17 00:00:00 2001 From: Pieter Date: Thu, 22 Sep 2022 11:41:13 +0200 Subject: [PATCH] bug: segmentation fault (#348) * refactor: makefile should track docker-compose.rendered.yml * bug: lock down tokio to prevent segmentation fault * refactor: comment need to pin crates --- Makefile | 2 +- service/Cargo.toml | 2 +- service/src/lib.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6aa646826..0e07dddc0 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ RUST_LOG?=debug DOCKER_COMPOSE_ENV=BACKEND_TAG=$(TAG) PROVISIONER_TAG=$(TAG) POSTGRES_TAG=latest APPS_FQDN=$(APPS_FQDN) DB_FQDN=$(DB_FQDN) POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) RUST_LOG=$(RUST_LOG) CONTAINER_REGISTRY=$(CONTAINER_REGISTRY) MONGO_INITDB_ROOT_USERNAME=$(MONGO_INITDB_ROOT_USERNAME) MONGO_INITDB_ROOT_PASSWORD=$(MONGO_INITDB_ROOT_PASSWORD) -.PHONY: images clean src up down deploy docker-compose.rendered.yml shuttle-% postgres docker-compose.rendered.yml test +.PHONY: images clean src up down deploy shuttle-% postgres test clean: rm .shuttle-* diff --git a/service/Cargo.toml b/service/Cargo.toml index b36571139..7764bfbbb 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -32,7 +32,7 @@ sqlx = { version = "0.6.1", optional = true } sync_wrapper = { version = "0.1.1", optional = true } thiserror = "1.0.32" tide = { version = "0.16.0", optional = true } -tokio = { version = "1.20.1", features = ["rt", "rt-multi-thread"] } +tokio = { version = "=1.20.1", features = ["rt", "rt-multi-thread"] } tower = { version = "0.4.13", features = ["make"], optional = true } # Tide does not have tokio support. So make sure async-std is compatible with tokio diff --git a/service/src/lib.rs b/service/src/lib.rs index b484b1cf3..b77779304 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -369,13 +369,14 @@ pub type StateBuilder = /// tokio runtime. pub type Binder = for<'a> fn(Box, SocketAddr, &'a Runtime) -> ServeHandle; +// Make sure every crate used in this struct has its version pinned down to prevent segmentation faults when crossing the FFI. +// Your future self will thank you! +// See https://github.com/shuttle-hq/shuttle/pull/348 #[allow(dead_code)] pub struct Bootstrapper { service: Option>, builder: Option>>, binder: Binder, - // Do you have time on your hands? If yes, then move this field higher and spend endless hours debugging the segmentation fault - // It seems that the [Runtime] changes in size when crossing the FFI which misaligns all fields after it runtime: Option, }