Strange regex panic cause by StripTags #50

Open
opened 2020-12-29 22:03:38 +00:00 by makeworld-the-better-one · 1 comment
makeworld-the-better-one commented 2020-12-29 22:03:38 +00:00 (Migrated from gitlab.com)

Here is the error as it appeared in the terminal. Unfortunately it was truncated and I can't scroll up and get the rest of it, as the panic messed up my terminal settings. It'd be nice if cview caught the errors, reset the terminal, and then panicked, but that's another thing.

                                      regexp.(*Regexp).replaceAll(0xc0002501e0, 0xc0003db2c0, 0xe4, 0xf0, 0x0, 0x0, 0x2, 0xc000102bb8, 0xe4, 0xf0, ...)
                                /usr/lib/go/src/regexp/regexp.go:634 +0x2fc
                                                                           regexp.(*Regexp).ReplaceAll(0xc0002501e0, 0xc0003db2c0, 0xe4, 0xf0, 0x0, 0x0, 0x0, 0xe4, 0x0, 0xc0003db2c0)
                                                                /usr/lib/go/src/regexp/regexp.go:675 +0x152
                                                                                                           gitlab.com/tslocum/cview.StripTags(0xc0003db2c0, 0xe4, 0xf0, 0xc000100101, 0x1, 0x1, 0xc0003db2c0)
                                                                                        /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/util.go:111 +0x169
                                                                      gitlab.com/tslocum/cview.(*TextView).GetBytes(0xc0001c6840, 0xc0003daf01, 0x0, 0x0, 0x0)
                                        /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/textview.go:337 +0x2e8
                          gitlab.com/tslocum/cview.(*TextView).GetText(...)
                                                                                /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/textview.go:343
                                                           gitlab.com/tslocum/cview.(*TabbedPanels).updateTabLabels(0xc000270180)
        /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:290 +0x83f
                                                                                                                           gitlab.com/tslocum/cview.(*TabbedPanels).updateAll(0xc000270180)
                                                                /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:335 +0x2b
                                                     gitlab.com/tslocum/cview.(*TabbedPanels).AddTab(0xc000270180, 0xb6772f, 0x1, 0xc000716360, 0x3, 0xc21b60, 0xc0005b2280)
                                                /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:86 +0xeb
                                    github.com/makeworld-the-better-one/amfora/display.Init.func1.1(0xc0000dac30)
                                                                                                                        /home/makeworld/go/src/github.com/makeworld-the-better-one/amfora/display/display.go:90 +0x199
                                                                                         created by github.com/makeworld-the-better-one/amfora/display.Init.func1
                                        /home/makeworld/go/src/github.com/makeworld-the-better-one/amfora/display/display.go:84 +0x70

Here's a picture if that's better:

Screenshot_2020-12-29_17-01-47

Sorry for the poor formatting, it's another terminal side effect. Basically the issue comes from StripTags. The stack trace starts at TabbedPanels.AddTab because that's what my code is doing, but I believe that's irrelevant. Strangely, the panic is coming from inside the stdlib's regexp package. The specific line causing the issue in StripTags is line 111:

		stripped = regionPattern.ReplaceAll(text, nil)

The furthest back I could trace the panic is from line 634 on regexp.go, which calls an anonymous function provided on lines 675-680 on regexp.go. Likely the call to re.expand in the function (line 679) is causing the panic.

Any ideas?

Here is the error as it appeared in the terminal. Unfortunately it was truncated and I can't scroll up and get the rest of it, as the panic messed up my terminal settings. It'd be nice if cview caught the errors, reset the terminal, and then panicked, but that's another thing. ``` regexp.(*Regexp).replaceAll(0xc0002501e0, 0xc0003db2c0, 0xe4, 0xf0, 0x0, 0x0, 0x2, 0xc000102bb8, 0xe4, 0xf0, ...) /usr/lib/go/src/regexp/regexp.go:634 +0x2fc regexp.(*Regexp).ReplaceAll(0xc0002501e0, 0xc0003db2c0, 0xe4, 0xf0, 0x0, 0x0, 0x0, 0xe4, 0x0, 0xc0003db2c0) /usr/lib/go/src/regexp/regexp.go:675 +0x152 gitlab.com/tslocum/cview.StripTags(0xc0003db2c0, 0xe4, 0xf0, 0xc000100101, 0x1, 0x1, 0xc0003db2c0) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/util.go:111 +0x169 gitlab.com/tslocum/cview.(*TextView).GetBytes(0xc0001c6840, 0xc0003daf01, 0x0, 0x0, 0x0) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/textview.go:337 +0x2e8 gitlab.com/tslocum/cview.(*TextView).GetText(...) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/textview.go:343 gitlab.com/tslocum/cview.(*TabbedPanels).updateTabLabels(0xc000270180) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:290 +0x83f gitlab.com/tslocum/cview.(*TabbedPanels).updateAll(0xc000270180) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:335 +0x2b gitlab.com/tslocum/cview.(*TabbedPanels).AddTab(0xc000270180, 0xb6772f, 0x1, 0xc000716360, 0x3, 0xc21b60, 0xc0005b2280) /home/makeworld/go/pkg/mod/gitlab.com/tslocum/cview@v1.5.3-0.20201228180808-c34e0954618b/tabbedpanels.go:86 +0xeb github.com/makeworld-the-better-one/amfora/display.Init.func1.1(0xc0000dac30) /home/makeworld/go/src/github.com/makeworld-the-better-one/amfora/display/display.go:90 +0x199 created by github.com/makeworld-the-better-one/amfora/display.Init.func1 /home/makeworld/go/src/github.com/makeworld-the-better-one/amfora/display/display.go:84 +0x70 ``` Here's a picture if that's better: ![Screenshot_2020-12-29_17-01-47](/uploads/5c07ce221e669a82800a0e2d414bb3f2/Screenshot_2020-12-29_17-01-47.png) Sorry for the poor formatting, it's another terminal side effect. Basically the issue comes from `StripTags`. The stack trace starts at `TabbedPanels.AddTab` because that's what my code is doing, but I believe that's irrelevant. Strangely, the panic is coming from inside the stdlib's `regexp` package. The specific line causing the issue in `StripTags` is line 111: ```go stripped = regionPattern.ReplaceAll(text, nil) ``` The furthest back I could trace the panic is from line 634 on `regexp.go`, which calls an anonymous function provided on lines 675-680 on `regexp.go`. Likely the call to `re.expand` in the function (line 679) is causing the panic. Any ideas?
makeworld-the-better-one commented 2021-01-01 03:14:04 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
tslocum added the
bug
label 2021-05-18 15:56:25 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tslocum/cview#50
There is no content yet.