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 widget.(*RichText).lineSizeToColumn #3292

Closed
2 tasks done
secsys-go opened this issue Sep 28, 2022 · 1 comment
Closed
2 tasks done

crash in widget.(*RichText).lineSizeToColumn #3292

secsys-go opened this issue Sep 28, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@secsys-go
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

We used the Fuzz engine to modify some Test(TestEntry_EraseSelection) data, and then the following crash appeared. Triggered when the value of the exported member (e.CursorColumn) is negative.

How to reproduce

The simplified test code is in Example code

Screenshots

CrashLog

panic: runtime error: slice bounds out of range [:-1] [recovered]
        panic: runtime error: slice bounds out of range [:-1]

goroutine 63 [running]:
testing.tRunner.func1.2({0x87e8c0, 0xc000024138})
        /home/zjx/.local/go/src/testing/testing.go:1211 +0x24e
testing.tRunner.func1()
        /home/zjx/.local/go/src/testing/testing.go:1214 +0x218
panic({0x87e8c0, 0xc000024138})
        /home/zjx/.local/go/src/runtime/panic.go:1038 +0x215
fyne.io/fyne/v2/widget.(*RichText).lineSizeToColumn(0xc0001c0580, 0xffffffffffffffff, 0x60)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/richtext.go:253 +0x33a
fyne.io/fyne/v2/widget.(*entryContentRenderer).buildSelection.func1(0x863a80, 0x0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1569 +0x2b
fyne.io/fyne/v2/widget.(*entryContentRenderer).buildSelection(0xc00012c1e0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1619 +0x512
fyne.io/fyne/v2/widget.(*entryContentRenderer).moveCursor(0xc00012c1e0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1665 +0x25
fyne.io/fyne/v2/widget.(*entryContentRenderer).Refresh(0xc00012c1e0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1533 +0x1b4
fyne.io/fyne/v2/widget.(*entryRenderer).Refresh(0xc0000207c0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1407 +0x482
fyne.io/fyne/v2/widget.(*BaseWidget).Refresh(0xc000213de0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/widget.go:138 +0x2e
fyne.io/fyne/v2/widget.(*BaseWidget).setFieldsAndRefresh(0xc00000c1e0, 0xc000213de8)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/widget.go:152 +0x71
fyne.io/fyne/v2/widget.(*Entry).updateText(0xc00000c1e0, {0xc000024120, 0x17})
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:1172 +0x7c
fyne.io/fyne/v2/widget.(*Entry).TypedKey(0xc00000c1e0, 0xc00000e390)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry.go:648 +0x605
fyne.io/fyne/v2/widget.TestEntry_EraseSelection.func1(0x855d00)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry_internal_test.go:242 +0x99
fyne.io/fyne/v2/widget.TestEntry_EraseSelection.func2(0xc00000e390)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry_internal_test.go:245 +0x2f
fyne.io/fyne/v2/widget.TestEntry_EraseSelection(0x0)
        /home/zjx/workspace/gowork/src/purelib/crashConfirm/fyne/widget/entry_internal_test.go:249 +0x163

Example code

//part of the Test Code
	e := NewMultiLineEntry()
	e.SetText("00000000000000000000000")
	e.CursorRow = 0
	e.CursorColumn = -1

	var keyDown = func(key *fyne.KeyEvent) {
		e.KeyDown(key)
		e.TypedKey(key)
	}
	var keyPress = func(key *fyne.KeyEvent) {
		keyDown(key)
		e.KeyUp(key)
	}
	keyDown(&fyne.KeyEvent{Name: desktop.KeyShiftLeft})
	keyPress(&fyne.KeyEvent{Name: fyne.KeyRight})

Fyne version

commit 638ae24 (HEAD -> master, origin/master, origin/HEAD)

Go compiler version

1.17.8

Operating system

Linux

Operating system version

OS: Linux r920 4.15.0-159-generic #167-Ubuntu

Additional Information

No response

@secsys-go secsys-go added the unverified A bug that has been reported but not verified label Sep 28, 2022
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jan 8, 2023
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Jan 9, 2023
@andydotxyz andydotxyz added this to the Fixes (v2.3.x) milestone Jan 9, 2023
@andydotxyz
Copy link
Member

Fixed on develop ready for next release

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants