Fixed dynlib features to not have UB when allocating.

This commit is contained in:
Sam 2023-01-26 21:26:36 -05:00
parent 1edd064611
commit e31668b188
12 changed files with 17 additions and 31 deletions

5
Cargo.lock generated
View File

@ -7012,7 +7012,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"itertools", "itertools",
"lazy_static", "lazy_static",
"mimalloc",
"rand 0.8.5", "rand 0.8.5",
"specs", "specs",
"tracing", "tracing",
@ -7045,6 +7044,8 @@ dependencies = [
"veloren-common-frontend", "veloren-common-frontend",
"veloren-common-net", "veloren-common-net",
"veloren-server", "veloren-server",
"veloren-server-agent",
"veloren-world",
] ]
[[package]] [[package]]
@ -7137,7 +7138,6 @@ version = "0.10.0"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"lazy_static", "lazy_static",
"mimalloc",
"vek 0.15.8", "vek 0.15.8",
"veloren-common", "veloren-common",
"veloren-common-dynlib", "veloren-common-dynlib",
@ -7187,7 +7187,6 @@ dependencies = [
"kiddo 0.2.4", "kiddo 0.2.4",
"lazy_static", "lazy_static",
"lz-fear", "lz-fear",
"mimalloc",
"minifb", "minifb",
"noise", "noise",
"num 0.4.0", "num 0.4.0",

View File

@ -645,8 +645,8 @@
abilities: [], abilities: [],
), ),
Custom("IcyTalharpa"): ( Custom("IcyTalharpa"): (
primary: "common.abilities.music.icy_talharpa", primary: Simple(None, "common.abilities.music.icy_talharpa"),
secondary: "common.abilities.music.icy_talharpa", secondary: Simple(None, "common.abilities.music.icy_talharpa"),
abilities: [], abilities: [],
), ),
Custom("Washboard"): ( Custom("Washboard"): (
@ -675,8 +675,8 @@
abilities: [], abilities: [],
), ),
Custom("DarkGuitar"): ( Custom("DarkGuitar"): (
primary: "common.abilities.music.dark_guitar", primary: Simple(None, "common.abilities.music.dark_guitar"),
secondary: "common.abilities.music.dark_guitar", secondary: Simple(None, "common.abilities.music.dark_guitar"),
abilities: [], abilities: [],
), ),
Custom("Sitar"): ( Custom("Sitar"): (

View File

@ -23,13 +23,17 @@ default = ["worldgen", "persistent_world"]
tracy = ["common-frontend/tracy"] tracy = ["common-frontend/tracy"]
plugins = ["server/plugins"] plugins = ["server/plugins"]
hot-reloading = ["server/hot-reloading"] hot-reloading = ["server/hot-reloading"]
hot-agent = ["server/hot-agent"]
hot-site = ["server/hot-site"]
[dependencies] [dependencies]
server = { package = "veloren-server", path = "../server", default-features = false, features = ["simd"] } server = { package = "veloren-server", path = "../server", default-features = false, features = ["simd"] }
agent = { package = "veloren-server-agent", path = "../server/agent" }
common = { package = "veloren-common", path = "../common" } common = { package = "veloren-common", path = "../common" }
common-base = { package = "veloren-common-base", path = "../common/base" } common-base = { package = "veloren-common-base", path = "../common/base" }
common-net = { package = "veloren-common-net", path = "../common/net" } common-net = { package = "veloren-common-net", path = "../common/net" }
common-frontend = { package = "veloren-common-frontend", path = "../common/frontend" } common-frontend = { package = "veloren-common-frontend", path = "../common/frontend" }
world = { package = "veloren-world", path = "../world" }
tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] } tokio = { version = "1.14", default-features = false, features = ["rt-multi-thread"] }
num_cpus = "1.0" num_cpus = "1.0"

View File

@ -1,7 +1,11 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![deny(clippy::clone_on_ref_ptr)] #![deny(clippy::clone_on_ref_ptr)]
#[cfg(target_os = "windows")] #[cfg(all(
target_os = "windows",
not(feature = "hot-agent"),
not(feature = "hot-site"),
))]
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

View File

@ -20,6 +20,3 @@ rand = { version = "0.8", features = ["small_rng"] }
tracing = "0.1" tracing = "0.1"
itertools = "0.10" itertools = "0.10"
lazy_static = "1.4.0" lazy_static = "1.4.0"
[target.'cfg(windows)'.dependencies]
mimalloc = "0.1.29"

View File

@ -795,7 +795,6 @@ impl<'a> AgentData<'a> {
e e
) )
}); });
controller.events.reserve(32);
attack_fn(self, agent, controller, tgt_data, read_data); attack_fn(self, agent, controller, tgt_data, read_data);
} }
} }

View File

@ -3,10 +3,6 @@
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
#[cfg(all(target_os = "windows", feature = "be-dyn-lib"))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
pub mod action_nodes; pub mod action_nodes;
pub mod attack; pub mod attack;
pub mod consts; pub mod consts;

View File

@ -20,6 +20,3 @@ common-dynlib = {package = "veloren-common-dynlib", path = "../../common/dynlib"
# Hot Reloading # Hot Reloading
lazy_static = {version = "1.4.0", optional = true} lazy_static = {version = "1.4.0", optional = true}
[target.'cfg(windows)'.dependencies]
mimalloc = "0.1.29"

View File

@ -3,10 +3,6 @@
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
#[cfg(all(target_os = "windows", feature = "be-dyn-lib"))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
macro_rules! skeleton_impls { macro_rules! skeleton_impls {
{ struct $Skeleton:ident { $( $(+)? $bone:ident ),* $(,)? $(:: $($field:ident : $field_ty:ty),* $(,)? )? } } => { { struct $Skeleton:ident { $( $(+)? $bone:ident ),* $(,)? $(:: $($field:ident : $field_ty:ty),* $(,)? )? } } => {
#[derive(Clone, Default)] #[derive(Clone, Default)]

View File

@ -6,7 +6,8 @@ mod cli;
#[cfg(all( #[cfg(all(
target_os = "windows", target_os = "windows",
not(feature = "tracy-memory"), not(feature = "tracy-memory"),
not(feature = "hot-egui") not(feature = "hot-egui"),
not(feature = "hot-anim"),
))] ))]
#[global_allocator] #[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;

View File

@ -78,6 +78,3 @@ required-features = ["bin_compression"]
[[example]] [[example]]
name = "heightmap_visualization" name = "heightmap_visualization"
required-features = ["bin_compression"] required-features = ["bin_compression"]
[target.'cfg(windows)'.dependencies]
mimalloc = "0.1.29"

View File

@ -65,10 +65,6 @@ use vek::*;
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))] #[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once"); compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
#[cfg(all(target_os = "windows", feature = "be-dyn-lib"))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[cfg(feature = "use-dyn-lib")] #[cfg(feature = "use-dyn-lib")]
use {common_dynlib::LoadedLib, lazy_static::lazy_static, std::sync::Arc, std::sync::Mutex}; use {common_dynlib::LoadedLib, lazy_static::lazy_static, std::sync::Arc, std::sync::Mutex};