Skip to content

rktp_refcnt leak in rd_kafka_toppar_leader_update #4375

@kwdubuc

Description

@kwdubuc

Description

In rd_kafka_toppar_leader_update, there is a potential reference leak of an rd_kafka_toppar_t object: rd_kafka_toppar_get increments the rktp_refcnt reference count, but the code path that returns due to outdated metadata leader epoch does not free that reference.

The following patch should correct this:

diff --git a/src/rdkafka_topic.c b/src/rdkafka_topic.c
index fbaa53bc..32fc3118 100644
--- a/src/rdkafka_topic.c
+++ b/src/rdkafka_topic.c
@@ -678,6 +678,7 @@ static int rd_kafka_toppar_leader_update(rd_kafka_topic_t *rkt,
                              rktp->rktp_leader_epoch);
                 if (rktp->rktp_fetch_state == RD_KAFKA_TOPPAR_FETCH_ACTIVE) {
                         rd_kafka_toppar_unlock(rktp);
+                        rd_kafka_toppar_destroy(rktp); /* from get() */
                         return 0;
                 }
         }

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

  • librdkafka version (release number or git tag): v2.2.0
  • Apache Kafka version:
  • librdkafka client configuration:
  • Operating system:
  • Provide logs (with debug=.. as necessary) from librdkafka
  • Provide broker log excerpts
  • Critical issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions