You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is related to a potential memory management bug in the deregisterBroker function of a Kafka client implemented in Go. Let’s break it down step by step:
Problem Source: Using a Pointer (*Broker) as Parameter
The parameter broker *Broker is a pointer.
Even if two brokers have the same ID(), they may be different pointers in memory.
// Different pointers, same broker IDb1:=&Broker{id: 1}
b2:=&Broker{id: 1} // same ID but different memory
The Bug:
client.brokers is a map from broker.ID() to *Broker. The function uses the ID to delete from the map:
delete(client.brokers, broker.ID())
This removes the key from the map, but not necessarily the correct pointer if two brokers have the same ID.
Also, there's no call to broker.Close() or similar cleanup so the memory (or any active connections/resources) held by the broker aren't released.
Summary of What’s wrong? Deregistering a broker by ID may remove the wrong broker (due to pointer mismatch), leaving the actual broker unclosed in memory. Cause Broker is passed as a pointer; broker with same ID might be a different object in memory.
The text was updated successfully, but these errors were encountered:
Heyo, cool works, and awesome
is related to a potential memory management bug in the deregisterBroker function of a Kafka client implemented in Go. Let’s break it down step by step:
Here’s the function in question:
What’s the issue?
Problem Source: Using a Pointer (*Broker) as Parameter
The Bug:
Summary
of What’s wrong? Deregistering a broker by ID may remove the wrong broker (due to pointer mismatch), leaving the actual broker unclosed in memory. Cause Broker is passed as a pointer; broker with same ID might be a different object in memory.The text was updated successfully, but these errors were encountered: