{"action":"closed","issue":{"url":"https://api.github.com/repos/golang/go/issues/24541","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/24541/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/24541/comments","events_url":"https://api.github.com/repos/golang/go/issues/24541/events","html_url":"https://github.com/golang/go/issues/24541","id":308686242,"number":24541,"title":"strings: unexpected nil pointer dereference on Replace","user":{"login":"blind-oracle","id":592248,"avatar_url":"https://avatars3.githubusercontent.com/u/592248?v=4","gravatar_id":"","url":"https://api.github.com/users/blind-oracle","html_url":"https://github.com/blind-oracle","followers_url":"https://api.github.com/users/blind-oracle/followers","following_url":"https://api.github.com/users/blind-oracle/following{/other_user}","gists_url":"https://api.github.com/users/blind-oracle/gists{/gist_id}","starred_url":"https://api.github.com/users/blind-oracle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blind-oracle/subscriptions","organizations_url":"https://api.github.com/users/blind-oracle/orgs","repos_url":"https://api.github.com/users/blind-oracle/repos","events_url":"https://api.github.com/users/blind-oracle/events{/privacy}","received_events_url":"https://api.github.com/users/blind-oracle/received_events","type":"User","site_admin":false},"labels":[{"id":373402289,"url":"https://api.github.com/repos/golang/go/labels/NeedsInvestigation","name":"NeedsInvestigation","color":"ededed","default":false},{"id":357033853,"url":"https://api.github.com/repos/golang/go/labels/WaitingForInfo","name":"WaitingForInfo","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/62","html_url":"https://github.com/golang/go/milestone/62","labels_url":"https://api.github.com/repos/golang/go/milestones/62/labels","id":2827591,"number":62,"title":"Go1.11","description":"","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":639,"closed_issues":492,"state":"open","created_at":"2017-10-10T13:39:17Z","updated_at":"2018-05-30T06:55:59Z","due_on":"2018-07-31T07:00:00Z","closed_at":null},"comments":9,"created_at":"2018-03-26T18:32:15Z","updated_at":"2018-05-30T06:55:59Z","closed_at":"2018-05-30T06:55:59Z","author_association":"NONE","body":"### What version of Go are you using (`go version`)?\r\n`go version go1.10 linux/amd64`\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n```\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/root/.cache/go-build\"\r\nGOEXE=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\nGOPATH=\"/root/go\"\r\nGORACE=\"\"\r\nGOROOT=\"/opt/go\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/opt/go/pkg/tool/linux_amd64\"\r\nGCCGO=\"gccgo\"\r\nCC=\"gcc\"\r\nCXX=\"g++\"\r\nCGO_ENABLED=\"1\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build061548367=/tmp/go-build\"\r\n```\r\n### What did you do?\r\nSadly I can't reproduce the issue, I can't even imagine how it could happen.\r\n\r\nVery rarely our service crashes in strings.Replace, because (for some impossible reason) it receives the first (string) argument as 0x0 (nil), according to the backtrace:\r\n\r\n```\r\npanic: runtime error: invalid memory address or nil pointer dereference\r\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x458675]\r\n\r\ngoroutine 25438489 [running]:\r\nstrings.Count(0x0, 0x7, 0xdd60a1, 0x1, 0xc456b46a68)\r\n        /opt/go/src/strings/strings_amd64.go:85 +0x96\r\nstrings.Replace(0x0, 0x7, 0xdd60a1, 0x1, 0xdd6242, 0x2, 0xffffffffffffffff, 0x20, 0x7)\r\n        /opt/go/src/strings/strings.go:847 +0x9b\r\n.../logrusformat.(*MTLogrusFormat).Format(0xc42018c600, 0xc45479ca50, 0x7ff3e3065c34, 0xc456b46c02, 0x21, 0xc456b46cf0, 0x411e2d)\r\n        .../logrusformat/format.go:80 +0x29b\r\n.../log/logrus-syslog-hook.(*SyslogHook).Fire(0xc42014cdc0, 0xc45479ca50, 0x2, 0xc420258238)\r\n        .../log/logrus-syslog-hook/syslog.go:80 +0x4dd\r\n```\r\n\r\nThe sample code snippet is:\r\n```\r\ntype F struct {}\r\n\r\nfunc (f *F) a() {\r\n x := \"whatever\"\r\n y := strings.Replace(f.b(x), `\"`, `\\\"`, -1)\r\n}\r\n\r\nfunc (f *F) b(i interface{}) string {\r\n return fmt.Sprintf(\"%v\", i)\r\n}\r\n```\r\n\r\nSo I'm calling some formatting method, which takes an interface and returns string.\r\nBy the way, I don't see this function call in the backtrace, it goes directly to Replace()->Count()\r\nAnd then somehow Replace() gets a nil address as a first arg.\r\n\r\nFrom what I can tell string can't be nil and this should not happen.\r\n\r\n### What did you expect to see?\r\nno panic\r\n\r\n### What did you see instead?\r\npanic\r\n"}}
{"actor":{"display_login":"blind-oracle"}}