From e58701d97c5feb089f3c230e50e52531333f5868 Mon Sep 17 00:00:00 2001 From: acetone <63557806+freeacetone@users.noreply.github.com> Date: Fri, 19 Jun 2026 16:15:51 +0300 Subject: [PATCH] fixed SAM crash on shared destination teardown --- libi2pd/Destination.cpp | 3 +++ libi2pd_client/SAM.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 5766f931..5e790290 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -1113,6 +1113,9 @@ namespace client void ClientDestination::Start () { + // Idempotent: a second Start() on a running destination must not re-create + // m_StreamingDestination (orphaning the live one) nor re-arm leaseset/pool. + if (m_StreamingDestination) return; LeaseSetDestination::Start (); m_StreamingDestination = std::make_shared (GetSharedFromThis ()); // TODO: m_StreamingDestination->Start (); diff --git a/libi2pd_client/SAM.cpp b/libi2pd_client/SAM.cpp index 24917625..34c24f54 100644 --- a/libi2pd_client/SAM.cpp +++ b/libi2pd_client/SAM.cpp @@ -1378,7 +1378,9 @@ namespace client void SAMSingleSession::StopLocalDestination () { - localDestination->Release (); + // Destination is ref-counted and may be shared by sessions whose SESSION + // CREATEs resolve to the same identity hash; only its last user may stop it. + if (localDestination->Release () > 0) return; // stop accepting new streams localDestination->StopAcceptingStreams (); // terminate existing streams