godchen0212 opened a new issue #498:
URL: https://github.com/apache/pulsar-client-go/issues/498


   The usage of range channel in connection.go line 334 is not correct. The 
range channel will be deadlock.
   
   Bug Code: 
https://github.com/apache/pulsar-client-go/blob/4d6c15114b9b6a0fc41b58993cf8acdd0e617b2f/pulsar/internal/connection.go#L334
 
   
   Reproduce method:
   ```go
   package main
   
   import (
        "fmt"
   )
   
   func main() {
        c := make(chan int, 10)
        for i := range c {
                fmt.Println(i)
        }
        close(c)
   }
   ```
   
   Output will be:
   ```
   fatal error: all goroutines are asleep - deadlock!
   
   goroutine 1 [chan receive]:
   main.main()
        /tmp/sandbox329282401/prog.go:9 +0xcb
   ```
   
   It can't be seen in pulsar for the main goroutines has exit. But exactly it 
remains in memory and cause goroutine and memory leak.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to