Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cast from alloc::string::String to alloc::string::String #47

Closed
mjhouse opened this issue Dec 25, 2021 · 1 comment · Fixed by #48
Closed

Invalid cast from alloc::string::String to alloc::string::String #47

mjhouse opened this issue Dec 25, 2021 · 1 comment · Fixed by #48

Comments

@mjhouse
Copy link

mjhouse commented Dec 25, 2021

I receive the following error while using the bevy_spicy_networking crate any time I try to send a message with a string in it. I'm not sure why it happens. It seems as if it shouldn't, since it's from String to String.

thread 'tokio-runtime-worker' panicked at 'invalid cast: alloc::string::String to alloc::string::String',
[...]/.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/any.rs:129:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

backtrace:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/panicking.rs:107:14
   2: erased_serde::any::Any::invalid_cast_to
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/any.rs:129:9
   3: erased_serde::any::Any::take
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/any.rs:104:13
   4: erased_serde::de::Out::take
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:254:9
   5: core::ops::function::FnOnce::call_once
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/ops/function.rs:227:5
   6: core::result::Result<T,E>::map
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/result.rs:767:25
   7: <&mut dyn erased_serde::de::MapAccess as serde::de::MapAccess>::next_value_seed
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:1037:9
   8: serde::de::MapAccess::next_value
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.130/src/de/mod.rs:1846:9
   9: <warfare::networking::messages::_::<impl serde::de::Deserialize for warfare::networking::messages::ChatMessage>::deserialize::__Visitor as serde::de::Visitor>::visit_map
             at ./src/networking/messages.rs:12:21
  10: <erased_serde::de::erase::Visitor<T> as erased_serde::de::Visitor>::erased_visit_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:583:9
  11: <&mut dyn erased_serde::de::Visitor as serde::de::Visitor>::visit_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:994:9
  12: <typetag::internally::MapWithStringKeys<A> as serde::de::Deserializer>::deserialize_struct
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/typetag-0.1.8/src/internally.rs:430:9
  13: <erased_serde::de::erase::Deserializer<T> as erased_serde::de::Deserializer>::erased_deserialize_struct
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:459:9
  14: <&mut dyn erased_serde::de::Deserializer as serde::de::Deserializer>::deserialize_struct
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:798:17
  15: warfare::networking::messages::_::<impl serde::de::Deserialize for warfare::networking::messages::ChatMessage>::deserialize
             at ./src/networking/messages.rs:12:21
  16: erased_serde::de::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/erased-serde-0.3.16/src/de.rs:39:5
  17: warfare::networking::messages::_::__init::__INVENTORY::{{closure}}
             at ./src/networking/messages.rs:17:1
  18: core::ops::function::FnOnce::call_once
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/ops/function.rs:227:5
  19: <typetag::de::FnApply<T> as serde::de::DeserializeSeed>::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/typetag-0.1.8/src/de.rs:55:9
  20: <typetag::internally::TaggedVisitor<T> as serde::de::Visitor>::visit_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/typetag-0.1.8/src/internally.rs:90:32
  21: serde_cbor::de::Deserializer<R>::parse_map::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:474:25
  22: serde_cbor::de::Deserializer<R>::recursion_checked
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:433:17
  23: serde_cbor::de::Deserializer<R>::parse_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:473:9
  24: serde_cbor::de::Deserializer<R>::parse_value
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:704:28
  25: <&mut serde_cbor::de::Deserializer<R> as serde::de::Deserializer>::deserialize_any
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:788:9
  26: <&mut serde_cbor::de::Deserializer<R> as serde::de::Deserializer>::deserialize_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.130/src/macros.rs:134:13
  27: typetag::internally::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/typetag-0.1.8/src/internally.rs:46:5
  28: bevy_spicy_networking::network_message::_NetworkMessage_registry::<impl serde::de::Deserialize for alloc::boxed::Box<dyn bevy_spicy_networking::network_message::NetworkMessage>>::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_spicy_networking-0.5.2/src/network_message.rs:3:1
  29: <core::marker::PhantomData<T> as serde::de::DeserializeSeed>::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.130/src/de/mod.rs:785:9
  30: <serde_cbor::de::MapAccess<R> as serde::de::MapAccess>::next_value_seed
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:1015:9
  31: serde::de::MapAccess::next_value
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.130/src/de/mod.rs:1846:9
  32: <bevy_spicy_networking::_::<impl serde::de::Deserialize for bevy_spicy_networking::NetworkPacket>::deserialize::__Visitor as serde::de::Visitor>::visit_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_spicy_networking-0.5.2/src/lib.rs:207:21
  33: serde_cbor::de::Deserializer<R>::parse_map::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:474:25
  34: serde_cbor::de::Deserializer<R>::recursion_checked
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:433:17
  35: serde_cbor::de::Deserializer<R>::parse_map
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:473:9
  36: serde_cbor::de::Deserializer<R>::parse_value
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:704:28
  37: <&mut serde_cbor::de::Deserializer<R> as serde::de::Deserializer>::deserialize_any
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:788:9
  38: <&mut serde_cbor::de::Deserializer<R> as serde::de::Deserializer>::deserialize_struct
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.130/src/macros.rs:134:13
  39: bevy_spicy_networking::_::<impl serde::de::Deserialize for bevy_spicy_networking::NetworkPacket>::deserialize
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_spicy_networking-0.5.2/src/lib.rs:207:21
  40: serde_cbor::de::from_slice
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/serde_cbor-0.11.2/src/de.rs:52:17
  41: bevy_spicy_networking::server::handle_new_incoming_connections::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_spicy_networking-0.5.2/src/server.rs:286:67
  42: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/future/mod.rs:80:19
  43: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/core.rs:161:17
  44: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/loom/std/unsafe_cell.rs:14:9
  45: tokio::runtime::task::core::CoreStage<T>::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/core.rs:151:13
  46: tokio::runtime::task::harness::poll_future::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:461:19
  47: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/panic/unwind_safe.rs:271:9
  48: std::panicking::try::do_call
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panicking.rs:406:40
  49: __rust_try
  50: std::panicking::try
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panicking.rs:370:19
  51: std::panic::catch_unwind
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panic.rs:133:14
  52: tokio::runtime::task::harness::poll_future
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:449:18
  53: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:98:27
  54: tokio::runtime::task::harness::Harness<T,S>::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:53:15
  55: tokio::runtime::task::raw::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/raw.rs:113:5
  56: tokio::runtime::task::raw::RawTask::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/raw.rs:70:18
  57: tokio::runtime::task::LocalNotified<S>::run
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/mod.rs:343:9
  58: tokio::runtime::thread_pool::worker::Context::run_task::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:420:13
  59: tokio::coop::with_budget::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:102:9
  60: std::thread::local::LocalKey<T>::try_with
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/thread/local.rs:399:16
  61: std::thread::local::LocalKey<T>::with
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/thread/local.rs:375:9
  62: tokio::coop::with_budget
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:95:5
  63: tokio::coop::budget
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/coop.rs:72:5
  64: tokio::runtime::thread_pool::worker::Context::run_task
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:419:9
  65: tokio::runtime::thread_pool::worker::Context::run
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:386:24
  66: tokio::runtime::thread_pool::worker::run::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:371:17
  67: tokio::macros::scoped_tls::ScopedKey<T>::set
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/macros/scoped_tls.rs:61:9
  68: tokio::runtime::thread_pool::worker::run
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:368:5
  69: tokio::runtime::thread_pool::worker::Launch::launch::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/thread_pool/worker.rs:347:45
  70: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/blocking/task.rs:42:21
  71: tokio::runtime::task::core::CoreStage<T>::poll::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/core.rs:161:17
  72: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/loom/std/unsafe_cell.rs:14:9
  73: tokio::runtime::task::core::CoreStage<T>::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/core.rs:151:13
  74: tokio::runtime::task::harness::poll_future::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:461:19
  75: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/core/src/panic/unwind_safe.rs:271:9
  76: std::panicking::try::do_call
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panicking.rs:406:40
  77: __rust_try
  78: std::panicking::try
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panicking.rs:370:19
  79: std::panic::catch_unwind
             at /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/std/src/panic.rs:133:14
  80: tokio::runtime::task::harness::poll_future
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:449:18
  81: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:98:27
  82: tokio::runtime::task::harness::Harness<T,S>::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/harness.rs:53:15
  83: tokio::runtime::task::raw::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/raw.rs:113:5
  84: tokio::runtime::task::raw::RawTask::poll
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/raw.rs:70:18
  85: tokio::runtime::task::UnownedTask<S>::run
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/task/mod.rs:379:9
  86: tokio::runtime::blocking::pool::Inner::run
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/blocking/pool.rs:264:17
  87: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at .../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.15.0/src/runtime/blocking/pool.rs:244:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@dtolnay
Copy link
Owner

dtolnay commented Dec 25, 2021

I published 0.3.17 removing the panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants