-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
Description
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
- Original PR: refactor: High level API for
TorrentandEngine#125 - Comment: refactor: High level API for
TorrentandEngine#125 (comment) - Reported by: @artrixdotdev
Metadata
Metadata
Assignees
Labels
Projects
Status
Done