SS-NT / ssnt

A remake of the game "Space Station 13" in 3D
20 stars 1 forks source link

target-cpu=native breaks client ability to connect to server inside container and remote server #41

Open Fogapod opened 9 months ago

Fogapod commented 9 months ago

Any network indirection (connecting to remote server or local/remote container) prevents client from spawning.

docker server command: run --name ssnt --network host --rm -e RUST_LOG=debug ssnt --public-address 127.0.0.1 (broken with both --network host and manual port)

After attempting to spawn as any role both client and server log connection once:

# client
2024-01-11T13:37:51.856986Z  INFO networking: Joining server 127.0.0.1:33998
2024-01-11T13:37:51.913513Z  INFO networking: Connected to server
2024-01-11T13:37:51.985569Z  INFO networking: Joined server tick=0.016666668

# server
024-01-11T13:37:51.937588Z  INFO networking: New client connected connection=ConnectionId(1704980271857) id="cceb82c6-047e-f4d0-cceb-82c6047ef4d0"

Next server log should be INFO ssnt::body: Created creature but it never gets there. Client is stuck in main menu. Hosting server outside container works and i cannot reproduce bug.

I tested a bunch of things so far, none of these change behaviour (local works, container doesnt):

I ran client in pdb and it seem to be stuck in some deadlock:

Traceback ```rust #0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 #1 0x00005555595cc101 in std::sys::unix::futex::futex_wait () at library/std/src/sys/unix/futex.rs:62 #2 std::sys::unix::locks::futex_condvar::Condvar::wait_optional_timeout () at library/std/src/sys/unix/locks/futex_condvar.rs:49 #3 std::sys::unix::locks::futex_condvar::Condvar::wait () at library/std/src/sys/unix/locks/futex_condvar.rs:33 #4 0x00005555594f9530 in std::sync::condvar::Condvar::wait<()> (self=0x55555a7026e0, guard=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sync/condvar.rs:189 #5 parking::Inner::park (self=0x55555a7026d0, timeout=...) at src/lib.rs:358 #6 0x00005555594b369a in futures_lite::future::block_on::{closure#0}, bevy_tasks::task_pool::{impl#2}::scope_with_executor_inner::{async_block_env#0}> (cache=...) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:91 #7 std::thread::local::LocalKey>::try_with, futures_lite::future::block_on::{closure_env#0}, bevy_tasks::task_pool::{impl#2}::scope_with_executor_inner::{async_block_env#0}>, alloc::vec::Vec<(), alloc::alloc::Global>> (self=, f=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270 #8 std::thread::local::LocalKey>::with, futures_lite::future::block_on::{closure_env#0}, bevy_tasks::task_pool::{impl#2}::scope_with_executor_inner::{async_block_env#0}>, alloc::vec::Vec<(), alloc::alloc::Global>> (f=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246 #9 futures_lite::future::block_on, bevy_tasks::task_pool::{impl#2}::scope_with_executor_inner::{async_block_env#0}> (future=...) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:79 #10 0x00005555594dc0d1 in bevy_tasks::task_pool::TaskPool::scope_with_executor_inner ( self=0x555559907988 , external_executor=, scope_executor=, tick_task_pool_executor=, f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_tasks/src/task_pool.rs:374 #11 0x00005555594dc0d1 in bevy_tasks::task_pool::{impl#2}::scope_with_executor::{closure#0} ( scope_executor=) #12 std::thread::local::LocalKey>::try_with, bevy_tasks::task_pool::{impl#2}::scope_with_executor::{closure_env#0}, alloc::vec::Vec<(), alloc::alloc::Global>> (f=..., self=) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:270 #13 std::thread::local::LocalKey>::with, bevy_tasks::task_pool::{impl#2}::scope_with_executor::{closure_env#0}, all oc::vec::Vec<(), alloc::alloc::Global>> (f=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/local.rs:246 #14 bevy_tasks::task_pool::TaskPool::scope_with_executor ( self=0x555559907988 , tick_task_pool_executor=false, external_executor=..., f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_tasks/src/task_pool.rs:307 #15 0x00005555594cee3f in bevy_ecs::schedule::executor::multi_threaded::{impl#2}::run (self=0x555559939730, schedule=0x7fffffff9458, world=0x7fffffffbb48) at src/schedule/executor/multi_threaded.rs:190 #16 0x0000555559476481 in bevy_ecs::world::{impl#3}::try_run_schedule::{closure#0}<&dyn bevy_ecs::schedule::set::ScheduleLabel> (world=0x7fffffffbb48, sched=0x7fffffff9068) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1851 #17 bevy_ecs::world::World::try_schedule_scope<(), &dyn bevy_ecs::schedule::set::ScheduleLabel, bevy_ecs::world::{impl#3}::try_run_schedule::{closure_env#0}<&dyn bevy_ecs::schedule::set::ScheduleLabel>> (self=0x7fffffffbb48, label=..., f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1782 #18 bevy_ecs::world::World::try_run_schedule<&dyn bevy_ecs::schedule::set::ScheduleLabel> (self=, label=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1851 #19 bevy_app::main_schedule::{impl#2}::run_main::{closure#0} (world=0x7fffffffbb48, order=...) at src/main_schedule.rs:146 #20 bevy_ecs::world::World::resource_scope (self=0x7fffffffbb48, f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1344 #21 0x000055555947e8c5 in core::ops::function::FnMut::call_mut), (&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local)> () at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:166 #22 core::ops::function::impls::{impl#3}::call_mut<(&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local), fn(&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local)> (args=..., self=) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:294 #23 bevy_ecs::system::exclusive_function_system::{impl#4}::run::call_inner<(), bevy_ecs::system::system_param::Local, &mut fn(&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local)> (f=0x555559911209, world=0x7fffffffbb48, F0=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/system/exclusive_function_system.rs:203 #24 bevy_ecs::system::exclusive_function_system::{impl#4}::run<(), fn(&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local), bevy_ecs::system::system_param::Local> (self=0x555559911209, world=0x7fffffffbb48, param_value=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/system/exclusive_function_system.rs:206 #25 bevy_ecs::system::exclusive_function_system::{impl#1}::run), fn(&mut bevy_ecs::world::World, bevy_ecs::system::system_param::Local)> (self=0x555559911140, input=, world=0x7fffffffbb48) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/system/exclusive_function_system.rs:103 #26 0x00005555594d1bdc in bevy_ecs::schedule::executor::single_threaded::{impl#0}::run::{closure#0} () at src/schedule/executor/single_threaded.rs:98 #27 core::ops::function::FnOnce::call_once () at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250 #28 core::panic::unwind_safe::{impl#23}::call_once<(), bevy_ecs::schedule::executor::single_threaded::{impl#0}::run::{closure_env#0}> (self=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272 #29 std::panicking::try::do_call, ()> ( data=) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552 #30 std::panicking::try<(), core::panic::unwind_safe::AssertUnwindSafe> (f=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516 #31 std::panic::catch_unwind, ()> (f=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142 #32 bevy_ecs::schedule::executor::single_threaded::{impl#0}::run (self=0x55555990d370, schedule=0x7fffffffa538, world=0x7fffffffbb48) at src/schedule/executor/single_threaded.rs:97 #33 0x0000555559476f0f in bevy_ecs::world::{impl#3}::run_schedule::{closure#0}<&dyn bevy_ecs::schedule::set::ScheduleLabel> (world=0x7fffffffbb48, sched=0x7fffffffa148) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1865 --Type for more, q to quit, c to continue without paging-- :ScheduleLabel>> (self=0x7fffffffbb48, label=..., f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1782 #35 bevy_ecs::world::World::schedule_scope<(), &dyn bevy_ecs::schedule::set::ScheduleLabel, bevy_ecs::world::{impl#3}::run_schedule::{closure_env#0}<&dyn bevy_ecs::schedule::set::ScheduleLabel>> (self=0x7fffffffbb48, label=..., f=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1836 #36 0x0000555559472d44 in bevy_ecs::world::World::run_schedule<&dyn bevy_ecs::schedule::set::ScheduleLabel> (self=, label=...) at /home/eugene/.local/share/cargo/git/checkouts/bevy-18d70155abbfd7e1/d5bdf5c/crates/bevy_ecs/src/world/mod.rs:1865 #37 bevy_app::app::App::update (self=0x55555a7026e0) at src/app.rs:244 #38 0x0000555557f14bac in bevy_winit::winit_runner::{closure#0} (event=..., event_loop=0x555559a324c0, control_flow=) at src/lib.rs:699 #39 0x0000555557eda205 in winit::platform_impl::platform::sticky_exit_callback<(), bevy_winit::winit_runner::{closure_env#0}> (evt=..., target=0x1abbe, control_flow=0x7fffffffb118, callback=0x7fffffffbb48) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/mod.rs:884 #40 winit::platform_impl::platform::x11::{impl#2}::run_return::single_iteration<(), bevy_winit::winit_runner::{closure_env#0}> (this=0x7fffffffb2a0, control_flow=0x7fffffffb118, cause=0x7fffffffb1a8, callback=0x7fffffffbb48) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/x11/mod.rs:358 #41 0x0000555557eda80b in winit::platform_impl::platform::x11::EventLoop<()>::run_return<(), bevy_winit::winit_runner::{closure_env#0}> (self=0x7fffffffb2a0, callback=...) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/x11/mod.rs:483 #42 0x0000555557edbfdd in winit::platform_impl::platform::x11::EventLoop<()>::run<(), bevy_winit::winit_runner::{closure_env#0}> (self=..., callback=) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/x11/mod.rs:498 #43 0x0000555557ec4810 in winit::platform_impl::platform::EventLoop<()>::run<(), bevy_winit::winit_runner::{closure_env#0}> (self=, callback=) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/platform_impl/linux/mod.rs:792 #44 winit::event_loop::EventLoop<()>::run<(), bevy_winit::winit_runner::{closure_env#0}> (event_handler=) at /home/eugene/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.7/src/event_loop.rs:305 #45 bevy_winit::run (event_handler=) at src/lib.rs:186 #46 bevy_winit::winit_runner (app=...) at src/lib.rs:787 #47 0x0000555557eb7484 in core::ops::function::FnOnce::call_once () at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250 #48 core::ops::function::FnOnce::call_once () at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250 #49 0x0000555559472f5c in alloc::boxed::{impl#47}::call_once<(bevy_app::app::App), (dyn core::ops::function::FnOnce<(bevy_app::app::App), Output=()> + core::marker::Send), alloc::alloc::Global> (self=..., args=...) at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015 #50 bevy_app::app::App::run (self=) at src/app.rs:292 #51 0x0000555556943b02 in ssnt::main () at src/main.rs:155 ```

I eventually discovered that "-C", "target-cpu=native" rustc flag causes this to happen. I am not sure how to debug this further

Fogapod commented 9 months ago
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-C", "link-arg=--ld-path=/usr/bin/mold", "-C", "target-cpu=native"]

removing "-C", "target-cpu=native" fixed this. i have no idea how it bugged out in a way game couldnt connect to container. there is a bug in linux or linkers or clang