{"action":"created","issue":{"url":"https://api.github.com/repos/rivo/tview/issues/67","repository_url":"https://api.github.com/repos/rivo/tview","labels_url":"https://api.github.com/repos/rivo/tview/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/rivo/tview/issues/67/comments","events_url":"https://api.github.com/repos/rivo/tview/issues/67/events","html_url":"https://github.com/rivo/tview/issues/67","id":303984667,"number":67,"title":"presentation demo, crash on table","user":{"login":"glycerine","id":445247,"avatar_url":"https://avatars2.githubusercontent.com/u/445247?v=4","gravatar_id":"","url":"https://api.github.com/users/glycerine","html_url":"https://github.com/glycerine","followers_url":"https://api.github.com/users/glycerine/followers","following_url":"https://api.github.com/users/glycerine/following{/other_user}","gists_url":"https://api.github.com/users/glycerine/gists{/gist_id}","starred_url":"https://api.github.com/users/glycerine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glycerine/subscriptions","organizations_url":"https://api.github.com/users/glycerine/orgs","repos_url":"https://api.github.com/users/glycerine/repos","events_url":"https://api.github.com/users/glycerine/events{/privacy}","received_events_url":"https://api.github.com/users/glycerine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-09T21:23:42Z","updated_at":"2018-03-10T00:28:09Z","closed_at":null,"author_association":"NONE","body":"`tview` looks fantastic. Thank you immensely for making this.\r\n\r\nI was playing with the demos/presentation app. On the (8) table tab, inside (n) navigation,\r\nif I use the down arrow key to scroll all the way to the bottom of the table, and then use the right arrow key to scroll all the way to the right, I seem to make it reliably crash.\r\n\r\n~~~\r\ngoroutine 1 [running]:\r\ngithub.com/rivo/tview.(*Application).Run.func1(0xc42012e2a0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/application.go:85 +0x82\r\npanic(0x118ff40, 0x1299f40)\r\n        /usr/local/go/src/runtime/panic.go:505 +0x229\r\ngithub.com/rivo/tview.(*Table).Draw(0xc4201d59a0, 0x11e5100, 0xc4200969c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/table.go:626 +0x239d\r\ngithub.com/rivo/tview.(*Flex).Draw(0xc4202bc3f0, 0x11e5100, 0xc4200969c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/flex.go:153 +0x464\r\ngithub.com/rivo/tview.(*Flex).Draw(0xc4202bc3c0, 0x11e5100, 0xc4200969c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/flex.go:153 +0x464\r\ngithub.com/rivo/tview.(*Pages).Draw(0xc42008c810, 0x11e5100, 0xc4200969c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/pages.go:242 +0xd8\r\ngithub.com/rivo/tview.(*Flex).Draw(0xc4202bd290, 0x11e5100, 0xc4200969c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/flex.go:153 +0x464\r\ngithub.com/rivo/tview.(*Application).Draw(0xc42012e2a0, 0xc4204fb5c0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/application.go:190 +0xcf\r\ngithub.com/rivo/tview.(*Application).Run(0xc42012e2a0, 0x0, 0x0)\r\n        /Users/jaten/go/src/github.com/rivo/tview/application.go:133 +0x2fd\r\nmain.main()\r\n        /Users/jaten/go/src/github.com/rivo/tview/demos/presentation/main.go:92 +0xa72\r\nexit status 2\r\n^[[Cjaten@Jasons-MacBook-Pro ~/go/src/github.com/rivo/tview/demos/presentation (master) $\r\n~~~"},"comment":{"url":"https://api.github.com/repos/rivo/tview/issues/comments/371983462","html_url":"https://github.com/rivo/tview/issues/67#issuecomment-371983462","issue_url":"https://api.github.com/repos/rivo/tview/issues/67","id":371983462,"user":{"login":"glycerine","id":445247,"avatar_url":"https://avatars2.githubusercontent.com/u/445247?v=4","gravatar_id":"","url":"https://api.github.com/users/glycerine","html_url":"https://github.com/glycerine","followers_url":"https://api.github.com/users/glycerine/followers","following_url":"https://api.github.com/users/glycerine/following{/other_user}","gists_url":"https://api.github.com/users/glycerine/gists{/gist_id}","starred_url":"https://api.github.com/users/glycerine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glycerine/subscriptions","organizations_url":"https://api.github.com/users/glycerine/orgs","repos_url":"https://api.github.com/users/glycerine/repos","events_url":"https://api.github.com/users/glycerine/events{/privacy}","received_events_url":"https://api.github.com/users/glycerine/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T00:28:09Z","updated_at":"2018-03-10T00:28:09Z","author_association":"NONE","body":"at https://github.com/rivo/tview/blob/master/table.go#L626\r\n\r\nwhen I log the index and widths, the crash happens when:\r\n\r\n`widths ='[]int{10, 9, 9}', len(widths)=3, index=3`\r\n\r\nthe relevant portion of table.go\r\n~~~\r\n\r\n    // If we have space left, distribute it.\r\n    if tableWidth < width {\r\n        toDistribute := width - tableWidth\r\n        for index, expansion := range expansions {\r\n            if expansionTotal <= 0 {\r\n                break\r\n            }\r\n            expWidth := toDistribute * expansion / expansionTotal\r\n            fmt.Fprintf(mylog, \"widths ='%#v', len(widths)=%v, index=%v\\n\", widths, len(widths), index)\r\n            widths[index] += expWidth        //<<<<<<<<<<< original line 626, where the crash is\r\n            tableWidth += expWidth\r\n            toDistribute -= expWidth\r\n            expansionTotal -= expansion\r\n        }\r\n    }\r\n~~~\r\n`index` is indeed out of bounds."}}
{"actor":{"display_login":"glycerine"}}