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
package main
import (
"log"
"net/http"
)
//delete this function, it would perform well
func useless_func(address string) []byte {
http.Get("https://www.google.com")
return nil
}
func test_a(test_channel chan int) {
test_channel <- 1
return
}
func test() {
test_channel := make(chan int)
for i := 0; i < 10; i++ {
go test_a(test_channel)
}
for {
log.Println(<-test_channel)
}
}
func main() {
test()
}
this code won't break because of clearly deadlock, it only happened under Linux with go 1.5.1. but if i delete useless_func and run it again, it would raise a deadlock error as expected.
The text was updated successfully, but these errors were encountered:
Importing the net package disables the deadlock detector. It has nothing to do with net/http or that func. For example, this also doesn't catch the deadlock:
To expand: The issue really lies with using cgo (which net uses, ignoring the details). When using cgo, the Go deadlock detection cannot function properly, because C world might call Go functions at any time, so in theory no deadlock exists; we might just be waiting for an external function call indefinitely.
this code won't break because of clearly deadlock, it only happened under Linux with go 1.5.1. but if i delete useless_func and run it again, it would raise a deadlock error as expected.
The text was updated successfully, but these errors were encountered: