Joylei / eip-rs

rseip - EIP&CIP client in pure Rust, for generic CIP and AB PLC
MIT License
47 stars 6 forks source link

Backtrace #7

Closed GeneL closed 2 years ago

GeneL commented 2 years ago

template instance: Template { instance_id: 1575, handle: 13998, member_count: 233, object_size: 1411, struct_size: 1868 } thread 'main' panicked at 'assertion failed: self.remaining() >= dst.len()', ../.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/buf/buf_impl.rs:253:9 stack backtrace: 0: rust_begin_unwind at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/core/src/panicking.rs:143:14 2: core::panicking::panic at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/core/src/panicking.rs:48:5 3: bytes::buf::buf_impl::Buf::copy_to_slice at ../.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/buf/buf_impl.rs:253:9 4: bytes::buf::buf_impl::Buf::get_u16_le at ../.cargo/registry/src/github.com-1ecc6299db9ec823/bytes-1.1.0/src/buf/buf_impl.rs:354:9 5: ::partial_decode at ./src/client/ab_eip/template/decoder.rs:60:39 6: rseip::client::ab_eip::template::TemplateRead<T,D>::call::{{closure}} at ./src/client/ab_eip/template.rs:197:13 7: <core::future::from_generator::GenFuture as core::future::future::Future>::poll at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/core/src/future/mod.rs:91:19 8: rseip::main::{{closure}} at ./src/main.rs:30:54 9: <core::future::from_generator::GenFuture as core::future::future::Future>::poll at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/core/src/future/mod.rs:91:19 10: tokio::park::thread::CachedParkThread::block_on::{{closure}} at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/park/thread.rs:263:54 11: tokio::coop::with_budget::{{closure}} at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:102:9 12: std::thread::local::LocalKey::try_with at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/std/src/thread/local.rs:413:16 13: std::thread::local::LocalKey::with at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/std/src/thread/local.rs:389:9 14: tokio::coop::with_budget at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:95:5 15: tokio::coop::budget at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:72:5 16: tokio::park::thread::CachedParkThread::block_on at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/park/thread.rs:263:31 17: tokio::runtime::enter::Enter::block_on at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/enter.rs:151:13 18: tokio::runtime::thread_pool::ThreadPool::block_on at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/mod.rs:73:9 19: tokio::runtime::Runtime::block_on at ../.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/mod.rs:477:43 20: rseip::main at ./src/main.rs:33:5 21: core::ops::function::FnOnce::call_once at /rustc/6a705566166debf5eff88c57140df607fa409aaa/library/core/src/ops/function.rs:227:5 note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Joylei commented 2 years ago

please try the code of perf branch, and let me know if it's working or not.

rseip={git="https://github.com/Joylei/eip-rs", branch="perf"}
GeneL commented 2 years ago

This backtrace is from the current code

Joylei commented 2 years ago

please try the perf branch

GeneL commented 2 years ago

It does not compile:

This is the code: let instance_id = 0x627; //0x376; //0x83b; //0x189; // here use a known instance_id, please uncomment below line to fetch one from PLC controller. //let instance_id = first_struct_instance(&mut client).await?.unwrap(); let template = client.find_template(instance_id).await?; println!("template instance:\n{:?}", template); let info = client.read_template(&template).call().await?; println!("template definition:\n{:?}", info);

This is the response:

error[E0716]: temporary value dropped while borrowed --> src/main.rs:36:17 36 let info = client.read_template(&template).call().await?; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
creates a temporary which is freed while still in use
37 println!("template definition:\n{:?}", info);
---- borrow later used here

= note: consider using a let binding to create a longer lived value

For more information about this error, try rustc --explain E0716. warning: rseip (bin "rseip") generated 6 warnings error: could not compile rseip due to previous error; 6 warnings emitted


From: joylei @.> Sent: Thursday, March 3, 2022 8:10 AM To: Joylei/eip-rs @.> Cc: Eugene Liberman @.>; Author @.> Subject: EXTERNAL: Re: [Joylei/eip-rs] Backtrace (Issue #7)

[Use caution with links & attachments]

please try the perf branch

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/Joylei/eip-rs/issues/7*issuecomment-1058026809__;Iw!!JhrIYaSK6lFZ!8mIeWsB3H3Ucd1EdHgpG-oamP8G8o9s-GDXIZ-IdvI8aRugLGF_AIrIcMVBBjLl1RKoH$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAHCUPZSCODXTFD7EEZTPJDU6C25PANCNFSM5PXOXAYA__;!!JhrIYaSK6lFZ!8mIeWsB3H3Ucd1EdHgpG-oamP8G8o9s-GDXIZ-IdvI8aRugLGF_AIrIcMVBBjDmOPynr$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!JhrIYaSK6lFZ!8mIeWsB3H3Ucd1EdHgpG-oamP8G8o9s-GDXIZ-IdvI8aRugLGF_AIrIcMVBBjGGp9WOR$ or Androidhttps://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!JhrIYaSK6lFZ!8mIeWsB3H3Ucd1EdHgpG-oamP8G8o9s-GDXIZ-IdvI8aRugLGF_AIrIcMVBBjFwioq2R$. You are receiving this because you authored the thread.Message ID: @.***>

Joylei commented 2 years ago

change your code like this

{
        let mut req = client.read_template(&template);
        let info = req.call().await?;
        println!("template definition:\n{:?}", info);
    }
GeneL commented 2 years ago

YES!! It works!


From: joylei @.> Sent: Thursday, March 3, 2022 8:54 AM To: Joylei/eip-rs @.> Cc: Eugene Liberman @.>; Author @.> Subject: EXTERNAL: Re: [Joylei/eip-rs] Backtrace (Issue #7)

[Use caution with links & attachments]

change your code like this

{ let mut req = client.read_template(&template); let info = req.call().await?; println!("template definition:\n{:?}", info); }

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/Joylei/eip-rs/issues/7*issuecomment-1058063757__;Iw!!JhrIYaSK6lFZ!88mYovDGyTON-SX0UgUZuqITfGNnJHRlXs6_AhRz4RDVoSYSnKNFlwj_00f4rzgMKD_e$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAHCUP4IG7Q56S656VNRIB3U6DABHANCNFSM5PXOXAYA__;!!JhrIYaSK6lFZ!88mYovDGyTON-SX0UgUZuqITfGNnJHRlXs6_AhRz4RDVoSYSnKNFlwj_00f4rwLFsgLz$. Triage notifications on the go with GitHub Mobile for iOShttps://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!JhrIYaSK6lFZ!88mYovDGyTON-SX0UgUZuqITfGNnJHRlXs6_AhRz4RDVoSYSnKNFlwj_00f4r0ihQ-HT$ or Androidhttps://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!JhrIYaSK6lFZ!88mYovDGyTON-SX0UgUZuqITfGNnJHRlXs6_AhRz4RDVoSYSnKNFlwj_00f4rwahV1iA$. You are receiving this because you authored the thread.Message ID: @.***>