Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in RedrawTerminal: index out of range #49

Open
Peter2121 opened this issue Apr 5, 2023 · 1 comment
Open

Crash in RedrawTerminal: index out of range #49

Peter2121 opened this issue Apr 5, 2023 · 1 comment

Comments

@Peter2121
Copy link

I have a new type of crash after rebuilding of cbsd-tui:

Exception has occurred: panic
"runtime error: index out of range [70] with length 70"
Stack:
	 3  0x0000000000648ce5 in github.com/gcla/gowid/widgets/text.(*ContentToCellArray).ProcessCell
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/text/text.go:499
	 4  0x0000000000646d93 in github.com/gcla/gowid/widgets/text.Content.RangeOver
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/text/text.go:173
	 5  0x000000000064baf8 in github.com/gcla/gowid/widgets/text.(*Content).RangeOver
	     at <autogenerated>:1
	 6  0x00000000006499cb in github.com/gcla/gowid/widgets/text.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/text/text.go:575
	 7  0x000000000064b754 in github.com/gcla/gowid/widgets/text.(*WidgetWithCursor).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/text/text.go:822
	 8  0x0000000000670b36 in github.com/gcla/gowid/widgets/edit.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/edit/edit.go:316
	 9  0x0000000000670574 in github.com/gcla/gowid/widgets/edit.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/edit/edit.go:289
	10  0x000000000062ad53 in github.com/gcla/gowid.(*ContainerWidget).Render
	     at <autogenerated>:1
	11  0x0000000000642c14 in github.com/gcla/gowid/widgets/columns.RenderSubWidgets
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:677
	12  0x000000000063d939 in github.com/gcla/gowid/widgets/columns.(*Widget).RenderSubWidgets
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:214
	13  0x0000000000641f5a in github.com/gcla/gowid/widgets/columns.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:620
	14  0x000000000063d7f4 in github.com/gcla/gowid/widgets/columns.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:210
	15  0x00000000007324ec in main.(*EditWithScrollbar).Render
	     at /home/peter/Programming/golang/cbsd-tui/editwithscrollbar.go:104
	16  0x0000000000668be9 in github.com/gcla/gowid/widgets/styled.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/styled/styled.go:113
	17  0x0000000000631974 in github.com/gcla/gowid/widgets/boxadapter.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/boxadapter/boxadapter.go:105
	18  0x0000000000631094 in github.com/gcla/gowid/widgets/boxadapter.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/boxadapter/boxadapter.go:71
	19  0x000000000064fa9c in github.com/gcla/gowid/widgets/framed.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/framed/framed.go:232
	20  0x000000000064ed94 in github.com/gcla/gowid/widgets/framed.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/framed/framed.go:182
	21  0x000000000062ad53 in github.com/gcla/gowid.(*ContainerWidget).Render
	     at <autogenerated>:1
	22  0x000000000066269a in github.com/gcla/gowid/widgets/pile.RenderSubwidgets.func1
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:495
	23  0x0000000000662b43 in github.com/gcla/gowid/widgets/pile.BoxMakerFunc.MakeBox
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:516
	24  0x0000000000663a91 in github.com/gcla/gowid/widgets/pile.RenderBoxMaker
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:667
	25  0x000000000065f9be in github.com/gcla/gowid/widgets/pile.(*Widget).RenderBoxMaker
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:219
	26  0x000000000066284e in github.com/gcla/gowid/widgets/pile.RenderSubwidgets
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:498
	27  0x000000000065f7f9 in github.com/gcla/gowid/widgets/pile.(*Widget).RenderSubWidgets
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:211
	28  0x0000000000661ac4 in github.com/gcla/gowid/widgets/pile.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:444
	29  0x000000000065f3f4 in github.com/gcla/gowid/widgets/pile.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:198
	30  0x000000000064fa9c in github.com/gcla/gowid/widgets/framed.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/framed/framed.go:232
	31  0x000000000064ed94 in github.com/gcla/gowid/widgets/framed.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/framed/framed.go:182
	32  0x0000000000668be9 in github.com/gcla/gowid/widgets/styled.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/styled/styled.go:113
	33  0x00000000006370f0 in github.com/gcla/gowid/widgets/cellmod.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/cellmod/cellmod.go:107
	34  0x0000000000636e54 in github.com/gcla/gowid/widgets/cellmod.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/cellmod/cellmod.go:97
	35  0x000000000066e173 in github.com/gcla/gowid/widgets/dialog.(*Widget).Render
	     at <autogenerated>:1
	36  0x0000000000657430 in github.com/gcla/gowid/widgets/padding.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/padding/padding.go:201
	37  0x0000000000657134 in github.com/gcla/gowid/widgets/padding.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/padding/padding.go:169
	38  0x000000000065ca27 in github.com/gcla/gowid/widgets/overlay.Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/overlay/overlay.go:310
	39  0x000000000065ba94 in github.com/gcla/gowid/widgets/overlay.(*Widget).Render
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/widgets/overlay/overlay.go:226
	40  0x000000000067e653 in github.com/gcla/gowid/widgets/holder.(*Widget).Render
	     at <autogenerated>:1
	41  0x00000000006135bf in github.com/gcla/gowid.RenderRoot
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/support.go:835
	42  0x00000000006048da in github.com/gcla/gowid.(*App).RedrawTerminal
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/app.go:726
	43  0x0000000000604085 in github.com/gcla/gowid.(*App).RunThenRenderEvent
	     at /home/peter/go/pkg/mod/github.com/gcla/[email protected]/app.go:670
	44  0x000000000072998a in main.ExecShellCommand.func1
	     at /home/peter/Programming/golang/cbsd-tui/cbsd-tui.go:780
@Peter2121
Copy link
Author

Quick and dirty fix:

--- text.go.bkp 2022-12-01 15:23:05.000000000 +0100
+++ text.go	2023-04-05 16:49:02.933408000 +0200
@@ -496,8 +496,10 @@
 var _ gowid.ICellProcessor = (*ContentToCellArray)(nil)

 func (m *ContentToCellArray) ProcessCell(cell gowid.Cell) gowid.Cell {
-	m.Cells[m.Cur] = cell
-	m.Cur += runewidth.RuneWidth(cell.Rune())
+	if len(m.Cells) > m.Cur {
+	        m.Cells[m.Cur] = cell
+	        m.Cur += runewidth.RuneWidth(cell.Rune())
+	}
 	return cell
 }

Peter2121 added a commit to Peter2121/gowid that referenced this issue Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant