Atostek/RustDDS

thread 'RustDDS discovery thread' panicked at 'range end index 2 out of range for slice of length 1'

Closed this issue · 1 comments

Sorry for flooding your inbox. This is the third issue (out of five), and I'm creating separate threads for them since their root causes differ.

In this case, BuiltinDataDeserializer::read_parameter_id is invoked on a DATA submessage that does not have any inlineQoS parameter, and panics.

  • Env: RustDDS 0.8.2, Ubuntu 20.04

  • RTPS message that triggers the panic:

Real-Time Publish-Subscribe Wire Protocol
    Magic: RTPS
    Protocol version: 2.2
    vendorId: 255.255 (Unknown)
    guidPrefix: 010f45d2b3f558b901000000
    Default port mapping: domainId=1, participantIdx=0, nature=UNICAST_METATRAFFIC
    submessageId: DATA (0x15)
        Flags: 0x05, Data present, Endianness bit
        octetsToNextHeader: 25
        0000 0000 0000 0000 = Extra flags: 0x0000
        Octets to inline QoS: 16
        readerEntityId: ENTITYID_UNKNOWN (0x00000000)
        writerEntityId: ENTITYID_BUILTIN_PARTICIPANT_WRITER (0x000100c2)
        writerSeqNumber: 2
        serializedData
            encapsulation kind: PL_CDR_LE (0x0003)
            Encapsulation options (0xffff90fe)
                Compression class Id: Unknown (7)
                Padding bytes: 2
  • Hexdump of above:
0000   00 00 03 04 00 06 00 00 00 00 00 00 00 00 08 00
0010   45 00 00 4d 00 01 40 00 40 11 3c 9d 7f 00 00 01
0020   7f 00 00 01 05 39 1d ec 00 39 4c 50 52 54 50 53
0030   02 02 ff ff 01 0f 45 d2 b3 f5 58 b9 01 00 00 00
0040   15 05 19 00 00 00 10 00 00 00 00 00 00 01 00 c2
0050   00 00 00 00 02 00 00 00 00 03 90 fe c7
  • Stderr and trace:
thread 'RustDDS discovery thread' panicked at 'range end index 2 out of range for slice of length 1', src/serialization/builtin_data_deserializer.rs:804:79
stack backtrace:
   0:     0x558ae1506e2a - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x558ae1506e2a - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x558ae1506e2a - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x558ae1506e2a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x558ae152c94f - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x558ae1503ea5 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x558ae1506bf5 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x558ae1506bf5 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x558ae150829e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x558ae1508045 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x558ae15087fe - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:691:13
  11:     0x558ae15086f9 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  12:     0x558ae1507296 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x558ae1508452 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  14:     0x558ae0cd5193 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  15:     0x558ae152ed92 - core::slice::index::slice_end_index_len_fail_rt::h47bd30d938cdf6bf
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/slice/index.rs:78:5
  16:     0x558ae0cd5756 - core::slice::index::slice_end_index_len_fail::hffd9449c48df793c
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/slice/index.rs:70:9
  17:     0x558ae12f27bc - <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index::h0d04bad5906daa91
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/slice/index.rs:411:13
  18:     0x558ae12f27fb - <core::ops::range::RangeTo<usize> as core::slice::index::SliceIndex<[T]>>::index::ha48812d5875ceeca
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/slice/index.rs:458:9
  19:     0x558ae12f20dc - core::slice::index::<impl core::ops::index::Index<I> for [T]>::index::hbb025b05f8bce1ee
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/slice/index.rs:19:9
  20:     0x558ae129fa4b - rustdds::serialization::builtin_data_deserializer::BuiltinDataDeserializer::read_parameter_id::hc516d52ec5f51d72
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/serialization/builtin_data_deserializer.rs:804:79
  21:     0x558ae12986f3 - rustdds::serialization::builtin_data_deserializer::BuiltinDataDeserializer::read_next::h641a0e80ada593d1
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/serialization/builtin_data_deserializer.rs:357:24
  22:     0x558ae1298538 - rustdds::serialization::builtin_data_deserializer::BuiltinDataDeserializer::parse_data::h7338008506e5c7cd
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/serialization/builtin_data_deserializer.rs:350:14
  23:     0x558ae108e9a6 - <rustdds::discovery::data_types::spdp_participant_data::SpdpDiscoveredParticipantData as rustdds::serialization::pl_cdr_deserializer::PlCdrDeserialize>::from_pl_cdr_bytes::h9de7e6fbec4e9406
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/discovery/data_types/spdp_participant_data.rs:174:5
  24:     0x558ae1261f5d - <rustdds::serialization::pl_cdr_deserializer::PlCdrDeserializerAdapter<D> as rustdds::dds::traits::serde_adapters::no_key::DeserializerAdapter<D>>::from_bytes::h162d7ec77e0555c1
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/serialization/pl_cdr_deserializer.rs:45:9
  25:     0x558ae10cb809 - rustdds::dds::with_key::simpledatareader::SimpleDataReader<D,DA>::deserialize::h2c6eb1351633b7de
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/with_key/simpledatareader.rs:257:17
  26:     0x558ae10cf0dd - rustdds::dds::with_key::simpledatareader::SimpleDataReader<D,DA>::try_take_one::h89bcd91b90a457f5
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/with_key/simpledatareader.rs:335:11
  27:     0x558ae11c5cdb - rustdds::dds::with_key::datareader::DataReader<D,DA>::fill_and_lock_local_datasample_cache::h249749be84db19f4
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/with_key/datareader.rs:106:13
  28:     0x558ae11c6ebb - rustdds::dds::with_key::datareader::DataReader<D,DA>::take::hcefa36004f72da23
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/with_key/datareader.rs:264:5
  29:     0x558ae11c7369 - rustdds::dds::with_key::datareader::DataReader<D,DA>::take_next_sample::h48b18f52d447fd38
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/with_key/datareader.rs:355:18
  30:     0x558ae113f217 - rustdds::discovery::discovery::Discovery::handle_participant_reader::hd7176ac0ec955919
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/discovery/discovery.rs:894:15
  31:     0x558ae113d2c6 - rustdds::discovery::discovery::Discovery::discovery_event_loop::h81b485e702f1f48f
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/discovery/discovery.rs:690:13
  32:     0x558ae10b1486 - rustdds::dds::participant::DomainParticipant::new::{{closure}}::h983c9a7b257f18d1
                               at /home/seulbae/ddssecurity/targets/RustDDS/src/dds/participant.rs:120:11
  33:     0x558ae0e91419 - std::sys_common::backtrace::__rust_begin_short_backtrace::h639316eb4fe1b328
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134:18
  34:     0x558ae0eb68c0 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h7061f5da033fe51a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:526:17
  35:     0x558ae0eaf1f4 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::haf733c7b0703d650
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panic/unwind_safe.rs:271:9
  36:     0x558ae10c4688 - std::panicking::try::do_call::h4526c5444bf8ead4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  37:     0x558ae10c4a2b - __rust_try
  38:     0x558ae10c45b8 - std::panicking::try::hfe3b9c8f5f3f50fd
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  39:     0x558ae0eb474a - std::panic::catch_unwind::h1cf9e2e7086c498a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  40:     0x558ae0eb66aa - std::thread::Builder::spawn_unchecked_::{{closure}}::hf78dfc90775c4583
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/mod.rs:525:30
  41:     0x558ae0e6d64f - core::ops::function::FnOnce::call_once{{vtable.shim}}::hf88a2cb2ee8b6873
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  42:     0x558ae150b925 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1f2224656a778fb
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  43:     0x558ae150b925 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::haa29ed9703f354b7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  44:     0x558ae150b925 - std::sys::unix::thread::Thread::new::thread_start::h33b6dae3e3692197
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7fb941674609 - start_thread
                               at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8
  46:     0x7fb941444133 - clone
                               at /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  47:                0x0 - <unknown>

Thank you.

Yes, this is again a genuine bug in 0.8.2. Thank you.

This panics 0.8.2, but latest master commit gives an error.

Resolving similarly to #278.