{"action":"created","issue":{"url":"https://api.github.com/repos/senorprogrammer/wtf/issues/235","repository_url":"https://api.github.com/repos/senorprogrammer/wtf","labels_url":"https://api.github.com/repos/senorprogrammer/wtf/issues/235/labels{/name}","comments_url":"https://api.github.com/repos/senorprogrammer/wtf/issues/235/comments","events_url":"https://api.github.com/repos/senorprogrammer/wtf/issues/235/events","html_url":"https://github.com/senorprogrammer/wtf/issues/235","id":337623245,"node_id":"MDU6SXNzdWUzMzc2MjMyNDU=","number":235,"title":"Rare crash in text view drawing","user":{"login":"baustinanki","id":9014288,"node_id":"MDQ6VXNlcjkwMTQyODg=","avatar_url":"https://avatars2.githubusercontent.com/u/9014288?v=4","gravatar_id":"","url":"https://api.github.com/users/baustinanki","html_url":"https://github.com/baustinanki","followers_url":"https://api.github.com/users/baustinanki/followers","following_url":"https://api.github.com/users/baustinanki/following{/other_user}","gists_url":"https://api.github.com/users/baustinanki/gists{/gist_id}","starred_url":"https://api.github.com/users/baustinanki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baustinanki/subscriptions","organizations_url":"https://api.github.com/users/baustinanki/orgs","repos_url":"https://api.github.com/users/baustinanki/repos","events_url":"https://api.github.com/users/baustinanki/events{/privacy}","received_events_url":"https://api.github.com/users/baustinanki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-02T18:43:12Z","updated_at":"2018-07-11T16:56:46Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"#### What's the problem?\r\n\r\nwtf crashes, randomly and after a long period of operation, with this callstack:\r\n\r\n```\r\npanic: runtime error: index out of range\r\ngoroutine 12 [running]:\r\n  github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview.(*TextView).Draw(0xc4201be0d0, 0x1753620, 0xc4200a76c0)\r\n    ~/go/src/github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview/textview.go:739 +0x1370\r\n  github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview.(*Grid).Draw(0xc4201a03f0, 0x1753620, 0xc4200a76c0)\r\n    ~/go/src/github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview/grid.go:582 +0x14ee\r\n  github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview.(*Pages).Draw(0xc4201b4750, 0x1753620, 0xc4200a76c0)\r\n    ~/go/src/github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview/pages.go:246 +0xf6\r\n  github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview.(*Application).Draw(0xc4201b1f80, 0x0)\r\n    ~/go/src/github.com/senorprogrammer/wtf/vendor/github.com/rivo/tview/application.go:265 +0xcf\r\n  main.redrawApp(0xc4201b1f80)\r\n    ~/go/src/github.com/senorprogrammer/wtf/wtf.go:106\r\n  created by main.main\r\n    ~/go/src/github.com/senorprogrammer/wtf/wtf.go:264 +0x31712)(Z)\r\n```\r\n\r\n\r\nI've had this happen twice, both times after a couple days of uptime w/ no issues. The code where this occurs in `textview.go` is here:\r\n\r\n```go\r\n\t\t// Get the text for this line.\r\n\t\tindex := t.index[line]\r\n\t\ttext := t.buffer[index.Line][index.Pos:index.NextPos]\r\n```\r\n\r\nI suspect the most likely reason for this is race conditions between text view drawing and text view updating - for example, if another routine was calling `SetText` on a text view while this code ran. It just occurred to me that I could build with `GOTRACEBACK=all` to get more detailed information on whether this is happening, so the next time this happens hopefully I can report back with more info."},"comment":{"url":"https://api.github.com/repos/senorprogrammer/wtf/issues/comments/404239961","html_url":"https://github.com/senorprogrammer/wtf/issues/235#issuecomment-404239961","issue_url":"https://api.github.com/repos/senorprogrammer/wtf/issues/235","id":404239961,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDIzOTk2MQ==","user":{"login":"senorprogrammer","id":6413,"node_id":"MDQ6VXNlcjY0MTM=","avatar_url":"https://avatars0.githubusercontent.com/u/6413?v=4","gravatar_id":"","url":"https://api.github.com/users/senorprogrammer","html_url":"https://github.com/senorprogrammer","followers_url":"https://api.github.com/users/senorprogrammer/followers","following_url":"https://api.github.com/users/senorprogrammer/following{/other_user}","gists_url":"https://api.github.com/users/senorprogrammer/gists{/gist_id}","starred_url":"https://api.github.com/users/senorprogrammer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senorprogrammer/subscriptions","organizations_url":"https://api.github.com/users/senorprogrammer/orgs","repos_url":"https://api.github.com/users/senorprogrammer/repos","events_url":"https://api.github.com/users/senorprogrammer/events{/privacy}","received_events_url":"https://api.github.com/users/senorprogrammer/received_events","type":"User","site_admin":false},"created_at":"2018-07-11T16:56:46Z","updated_at":"2018-07-11T16:56:46Z","author_association":"OWNER","body":"Agreed. I've seen this and think your reasoning is sound. I haven't yet traced exactly where it's happening but I suspect adding a `mutex.Lock()` around the widgets that use `pages.go` might solve the issue."}}
{"actor":{"display_login":"senorprogrammer"}}