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

Application crashes sometimes in RedrawTerminal #47

Open
Peter2121 opened this issue Aug 10, 2022 · 2 comments
Open

Application crashes sometimes in RedrawTerminal #47

Peter2121 opened this issue Aug 10, 2022 · 2 comments

Comments

@Peter2121
Copy link

...with the following error in console:

panic: interface conversion: gowid.RenderFixed is not gowid.IRenderWithWeight: missing method Weight
goroutine 1 [running]:
github.com/gcla/gowid/widgets/columns.widgetWidthsExt({0x828115490, 0xc000177130}, {0xc0015141e0, 0xa, 0xa}, {0xc001514280, 0xa, 0xa}, {0x264e20, 0xc000a4a080}, ...)
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:550 +0xc98
github.com/gcla/gowid/widgets/columns.WidgetWidths({0x2ccda0, 0xc000177130}, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:430 +0x19a
github.com/gcla/gowid/widgets/columns.(*Widget).WidgetWidths(0xc000177130, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:225 +0x8e
github.com/gcla/gowid/widgets/columns.RenderSubWidgets({0x2d2488, 0xc000177130}, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:665 +0x156
github.com/gcla/gowid/widgets/columns.(*Widget).RenderSubWidgets(0xc000177130, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:214 +0x8e
github.com/gcla/gowid/widgets/columns.Render({0x2d2488, 0xc000177130}, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:620 +0x13c
github.com/gcla/gowid/widgets/columns.(*Widget).Render(0xc000177130, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/columns/columns.go:210 +0x78
github.com/gcla/gowid/widgets/pile.RenderSubwidgets.func1({0x2cdd98, 0xc0001c98e0}, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:495 +0x72
github.com/gcla/gowid/widgets/pile.BoxMakerFunc.MakeBox(0x28cfa0, {0x2cdd98, 0xc0001c98e0}, {0x264e20, 0xc000a4a080}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:516 +0x84
github.com/gcla/gowid/widgets/pile.RenderBoxMaker({0x2d2550, 0xc0001d4280}, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500}, {0x2ca6e0, ...})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:583 +0x710
github.com/gcla/gowid/widgets/pile.(*Widget).RenderBoxMaker(0xc0001d4280, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500}, {0x2ca6e0, 0x28cfa0})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:219 +0xbf
github.com/gcla/gowid/widgets/pile.RenderSubwidgets({0x2d2550, 0xc0001d4280}, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:498 +0xba
github.com/gcla/gowid/widgets/pile.(*Widget).RenderSubWidgets(0xc0001d4280, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:211 +0x8e
github.com/gcla/gowid/widgets/pile.Render({0x2d2550, 0xc0001d4280}, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:444 +0xc2
github.com/gcla/gowid/widgets/pile.(*Widget).Render(0xc0001d4280, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:198 +0x78
github.com/gcla/gowid/widgets/pile.RenderSubwidgets.func1({0x2cdd98, 0xc0001c99a0}, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:495 +0x72
github.com/gcla/gowid/widgets/pile.BoxMakerFunc.MakeBox(0x28cfa0, {0x2cdd98, 0xc0001c99a0}, {0x264e20, 0xc000a4a050}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:516 +0x84
github.com/gcla/gowid/widgets/pile.RenderBoxMaker({0x2d2550, 0xc0001d4300}, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500}, {0x2ca6e0, ...})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:658 +0xba2
github.com/gcla/gowid/widgets/pile.(*Widget).RenderBoxMaker(0xc0001d4300, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500}, {0x2ca6e0, 0x28cfa0})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:219 +0xbf
github.com/gcla/gowid/widgets/pile.RenderSubwidgets({0x2d2550, 0xc0001d4300}, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:498 +0xba
github.com/gcla/gowid/widgets/pile.(*Widget).RenderSubWidgets(0xc0001d4300, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, 0x0, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:211 +0x8e
github.com/gcla/gowid/widgets/pile.Render({0x2d2550, 0xc0001d4300}, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:444 +0xc2
github.com/gcla/gowid/widgets/pile.(*Widget).Render(0xc0001d4300, {0x264e20, 0xc000a4a000}, {0x0, 0x0}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/pile/pile.go:198 +0x78
github.com/gcla/gowid/widgets/overlay.Render({0x2d0780, 0xc00155ed20}, {0x264e20, 0xc000a4a000}, {0x1, 0x1}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/overlay/overlay.go:304 +0xf9
github.com/gcla/gowid/widgets/overlay.(*Widget).Render(0xc00155ed20, {0x264e20, 0xc000a4a000}, {0x1, 0x1}, {0x2d2618, 0xc000194500})
        /root/go/pkg/mod/github.com/gcla/[email protected]/widgets/overlay/overlay.go:226 +0x78
github.com/gcla/gowid.RenderRoot({0x2ce000, 0xc0001c9a20}, 0xc000194500)
        /root/go/pkg/mod/github.com/gcla/[email protected]/support.go:835 +0xfa
github.com/gcla/gowid.(*App).RedrawTerminal(0xc000194500)
        /root/go/pkg/mod/github.com/gcla/[email protected]/app.go:719 +0x3d
github.com/gcla/gowid.(*App).HandleTCellEvent(0xc000194500, {0x255280, 0xc000933e40}, {0x2ca900, 0x869498})
        /root/go/pkg/mod/github.com/gcla/[email protected]/app.go:501 +0xadd
github.com/gcla/gowid.(*App).handleEvents(0xc000194500, {0x2ca900, 0x869498})
        /root/go/pkg/mod/github.com/gcla/[email protected]/app.go:675 +0x145
github.com/gcla/gowid.(*App).MainLoop(0xc000194500, {0x2ca900, 0x869498})
        /root/go/pkg/mod/github.com/gcla/[email protected]/app.go:656 +0x129
main.main()
        /root/cbsd-tui/cbsd-tui.go:1265 +0x32b2

cbsd-tui.go:1265 is just app.MainLoop(handler{})

The problem arrives when I update a dialog (with edit widget inside) in cycle showing the output of a command as it comes. The dialog is created as follows:

func CreateActionsLogDialog(editWidget *edit.Widget) *dialog.Widget {
	baheight := cbsdJailConsole.Height()
	ba := boxadapter.New(
		styled.New(
			NewEditWithScrollbar(editWidget),
			gowid.MakePaletteRef("white"),
		),
		baheight,
	)
	actionlogdialog := dialog.New(
		framed.NewUnicode(ba),
		dialog.Options{
			Buttons:         []dialog.Button{dialog.CloseD},
			Modal:           true,
			NoShadow:        true,
			TabToButtons:    true,
			BackgroundStyle: gowid.MakePaletteRef("bluebg"),
			BorderStyle:     gowid.MakePaletteRef("dialog"),
			ButtonStyle:     gowid.MakePaletteRef("white-focus"),
			FocusOnWidget:   true,
		},
	)
	return actionlogdialog
}

NewEditWithScrollbar is taken from editor example.

I suppose that there are some race conditions somewhere...

@gcla
Copy link
Owner

gcla commented Aug 27, 2022

Hi @Peter2121 - I'm sorry for the slow support lately.

This backtrace has me puzzled. Is there any chance you have local modifications to the columns widget? The reason I ask is that at line 550 in columns.go, this cast is failing:

for i := 0; i < lenw; i++ {
	// Can only be weight here if !helper[i] ; but not sufficient for it to be eligible
	if !widthHelper[i] {
		cols := int(((float32(dims[i].(gowid.IRenderWithWeight).Weight()) / float32(totalWeight)) * float32(colsToDivideUp)) + 0.5)     // <--- cast to IRenderWithWeight fails
                ...
        }
   ...
}

But at line 475, prior to the failure, this code runs:

for i := 0; i < lenw; i++ {
   switch w2 := dims[i].(type) {
   case gowid.IRenderFixed:
           ...
   	widthHelper[i] = true     // <--- puzzle
           ...
   }
   ...
}

The error indicates an invalid cast from gowid.RenderFixed to gowid.IRenderWithWeight.

@Peter2121
Copy link
Author

I've just checked the sources of the module github.com/gcla/gowid v1.4.1-0.20220717013040-1d7a75b6f5cb declared in go.mod - there is the same code in columns.go. So, for sure, there are no local modifications here.

I think, the important point here is that it works correctly in 95% of cases and crashes sometimes.

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

2 participants