From a39d259bb4cacebd54ae04095894d2088086384e Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sun, 31 Mar 2024 10:56:04 -0400 Subject: [PATCH] Switch nix-shell to use oxalica overlay to get miri working, fix memory leak in archetypes --- lyra-ecs/src/archetype.rs | 4 +++- rust-toolchain.toml | 4 ++-- shell.nix | 16 +++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lyra-ecs/src/archetype.rs b/lyra-ecs/src/archetype.rs index 5ea7b55..9b431f4 100644 --- a/lyra-ecs/src/archetype.rs +++ b/lyra-ecs/src/archetype.rs @@ -19,7 +19,9 @@ impl Drop for ComponentColumn { unsafe { // TODO: trigger drop on the components - let layout = self.info.layout(); + // SAFETY: The size of the data buffer is the capcity times the size of a component + let size = self.info.layout().size() * self.capacity; + let layout = Layout::from_size_align_unchecked(size, self.info.layout().align()); dealloc(data, layout); } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 78cfb42..50b32f7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly" -date = "2023-11-21" +channel = "nightly-2023-11-21" +#date = "2023-11-21" targets = [ "x86_64-unknown-linux-gnu" ] \ No newline at end of file diff --git a/shell.nix b/shell.nix index f0620b7..a4c7fef 100755 --- a/shell.nix +++ b/shell.nix @@ -1,6 +1,10 @@ let - moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); - nixpkgs = import { overlays = [ moz_overlay ]; }; + rust_overlay = import (builtins.fetchTarball https://github.com/oxalica/rust-overlay/archive/master.tar.gz); + nixpkgs = import { overlays = [ rust_overlay ]; }; + + rust = (nixpkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { + extensions = [ "rust-analysis" "rust-src" "miri-preview" ]; + }; in with nixpkgs; stdenv.mkDerivation rec { @@ -15,13 +19,7 @@ in mold udev lua5_4_compat - ((nixpkgs.rustChannelOf { rustToolchain = ./rust-toolchain.toml; }).rust.override { - extensions = [ - "rust-src" - "rust-analysis" - "miri-preview" - ]; - }) + rust ]; buildInputs = [ udev alsa-lib libGL gcc