Problem
In crates/libtortillas/src/engine/actor.rs around lines 133-134, there's a potential panic when calling actor_ref.upgrade().unwrap() in the TCP and uTP peer stream handling logic.
Current Code
Some(Signal::Message {
message: Box::new(EngineMessage::IncomingPeer(peer_stream)),
actor_ref: actor_ref.upgrade().unwrap(),
reply: None,
sent_within_actor: true,
})
Issue
If the weak actor reference upgrade fails (returns None), the application will panic. This can happen in legitimate scenarios where the actor has been dropped.
Suggested Fix
Handle the upgrade failure gracefully:
let Some(actor_ref) = actor_ref.upgrade() else {
error!("Failed to upgrade weak actor reference");
return None;
};
Some(Signal::Message {
message: Box::new(EngineMessage::IncomingPeer(peer_stream)),
actor_ref,
reply: None,
sent_within_actor: true,
})
Context
This issue affects both TCP and uTP peer stream handling in the EngineActor::next method.
Backlinks
Problem
In
crates/libtortillas/src/engine/actor.rsaround lines 133-134, there's a potential panic when callingactor_ref.upgrade().unwrap()in the TCP and uTP peer stream handling logic.Current Code
Issue
If the weak actor reference upgrade fails (returns None), the application will panic. This can happen in legitimate scenarios where the actor has been dropped.
Suggested Fix
Handle the upgrade failure gracefully:
Context
This issue affects both TCP and uTP peer stream handling in the
EngineActor::nextmethod.Backlinks
TorrentandEngine#125TorrentandEngine#125 (comment)