Skip to content

Commit

Permalink
bug: segmentation fault (#348)
Browse files Browse the repository at this point in the history
* refactor: makefile should track docker-compose.rendered.yml

* bug: lock down tokio to prevent segmentation fault

* refactor: comment need to pin crates
  • Loading branch information
chesedo authored Sep 22, 2022
1 parent dbfb0ee commit 995e1e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
Expand Down
2 changes: 1 addition & 1 deletion service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,14 @@ pub type StateBuilder<T> =
/// tokio runtime.
pub type Binder = for<'a> fn(Box<dyn Service>, 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<Box<dyn Service>>,
builder: Option<StateBuilder<Box<dyn Service>>>,
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<Runtime>,
}

Expand Down

0 comments on commit 995e1e3

Please sign in to comment.