{"action":"created","issue":{"url":"https://api.github.com/repos/gocql/gocql/issues/439","labels_url":"https://api.github.com/repos/gocql/gocql/issues/439/labels{/name}","comments_url":"https://api.github.com/repos/gocql/gocql/issues/439/comments","events_url":"https://api.github.com/repos/gocql/gocql/issues/439/events","html_url":"https://github.com/gocql/gocql/issues/439","id":93332300,"number":439,"title":"panic: nil reference in framer.readFrame on f.readBuffer","user":{"login":"dankinder","id":5198575,"avatar_url":"https://avatars.githubusercontent.com/u/5198575?v=3","gravatar_id":"","url":"https://api.github.com/users/dankinder","html_url":"https://github.com/dankinder","followers_url":"https://api.github.com/users/dankinder/followers","following_url":"https://api.github.com/users/dankinder/following{/other_user}","gists_url":"https://api.github.com/users/dankinder/gists{/gist_id}","starred_url":"https://api.github.com/users/dankinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dankinder/subscriptions","organizations_url":"https://api.github.com/users/dankinder/orgs","repos_url":"https://api.github.com/users/dankinder/repos","events_url":"https://api.github.com/users/dankinder/events{/privacy}","received_events_url":"https://api.github.com/users/dankinder/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-07-06T17:29:26Z","updated_at":"2015-07-17T18:46:13Z","closed_at":null,"body":"We recently had gocql panic with the trace below (go 1.4, GOMAXPROCS=8). Our application does many millions of reads and writes daily and gocql has been stable; I have only seen this exception once.\r\n\r\nIt seems to be a nil reference in frame.go:365, which in my version of the codebase (we generally just use master) is this:\r\n```go\r\n    if cap(f.readBuffer) >= head.length {\r\n```\r\nIt seems unlikely that head would be nil since it was referenced previously in this function so `f.readBuffer` seems the likely culprit. Two lines down I do see:\r\n```go\r\n        f.readBuffer = make([]byte, head.length)\r\n```\r\nIf readFrame could be called concurrently then I believe this operation is not safe. I haven't personally run the [race detector](https://golang.org/doc/articles/race_detector.html) on this code but that may help.\r\n\r\n```\r\n2015/07/03 07:01:39 connect: failed to connect to \"10.5.24.113:9042\": gocql: no response recieved from cassandra within timeout period                                                                             \r\npanic: runtime error: invalid memory address or nil pointer dereference                                                                                                                                            \r\n[signal 0xb code=0x1 addr=0x70 pc=0x727b99]                                                                                                                                                                        \r\n                                                                                                                                                                                                                   \r\ngoroutine 20188720 [running]:                                                                                                                                                                                      \r\ngithub.com/gocql/gocql.(*framer).readFrame(0x0, 0xc2657174a0, 0x0, 0x0)                                                                                                                                            \r\n    /var/lib/jenkins/jobs/walker-master-build/gopath/src/github.com/gocql/gocql/frame.go:365 +0x309                                                                                                                \r\ngithub.com/gocql/gocql.(*Conn).recv(0xc27dc3d6c0, 0x0, 0x0)                                                                                                                                                        \r\n    /var/lib/jenkins/jobs/walker-master-build/gopath/src/github.com/gocql/gocql/conn.go:330 +0x1c7                                                                                                                 \r\ngithub.com/gocql/gocql.(*Conn).serve(0xc27dc3d6c0)                                                                                                                                                                 \r\n    /var/lib/jenkins/jobs/walker-master-build/gopath/src/github.com/gocql/gocql/conn.go:305 +0x3a                                                                                                                  \r\ncreated by github.com/gocql/gocql.Connect                                                                                                                                                                          \r\n    /var/lib/jenkins/jobs/walker-master-build/gopath/src/github.com/gocql/gocql/conn.go:187 +0x727\r\n```"},"comment":{"url":"https://api.github.com/repos/gocql/gocql/issues/comments/122371025","html_url":"https://github.com/gocql/gocql/issues/439#issuecomment-122371025","issue_url":"https://api.github.com/repos/gocql/gocql/issues/439","id":122371025,"user":{"login":"Zariel","id":2213,"avatar_url":"https://avatars.githubusercontent.com/u/2213?v=3","gravatar_id":"","url":"https://api.github.com/users/Zariel","html_url":"https://github.com/Zariel","followers_url":"https://api.github.com/users/Zariel/followers","following_url":"https://api.github.com/users/Zariel/following{/other_user}","gists_url":"https://api.github.com/users/Zariel/gists{/gist_id}","starred_url":"https://api.github.com/users/Zariel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zariel/subscriptions","organizations_url":"https://api.github.com/users/Zariel/orgs","repos_url":"https://api.github.com/users/Zariel/repos","events_url":"https://api.github.com/users/Zariel/events{/privacy}","received_events_url":"https://api.github.com/users/Zariel/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T18:46:13Z","updated_at":"2015-07-17T18:46:13Z","body":"Thanks, thats really odd. It might be worth adding a check to exec before the call to call.framer.readFrame to check if framer is nil, and log out the streamID.\r\n\r\nIf it does not trigger a race condition then there is something very strange going on. I created a stress test benchmark which uncovered an issue which I thought was causing this one but apparently not. What conditions are creating this (num conns, streams, protocol version, req/s)? Thanks again for trying to debug this."}}