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

panic: runtime error: slice bounds out of range #127

Open
iambus opened this issue Dec 13, 2021 · 2 comments · May be fixed by #128
Open

panic: runtime error: slice bounds out of range #127

iambus opened this issue Dec 13, 2021 · 2 comments · May be fixed by #128

Comments

@iambus
Copy link

iambus commented Dec 13, 2021

func TestPatchMakeOutOfRangePanic(t *testing.T) {
	text1 := `
  1111111111111 000000
  ------------- ------
  xxxxxxxxxxxxx ------
  xxxxxxxxxxxxx ------
  xxxxxxxxxxxxx xxxxxx
  xxxxxxxxxxxxx ......
  xxxxxxxxxxxxx 111111
  xxxxxxxxxxxxx ??????
  xxxxxxxxxxxxx 333333
  xxxxxxxxxxxxx 555555
  xxxxxxxxxx xxxxx
  xxxxxxxxxx xxxxx
  xxxxxxxxxx xxxxx
  xxxxxxxxxx xxxxx
`
	text2 := `
  2222222222222 000000
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`
	dmp := New()
	patches := dmp.PatchMake(text1, text2)
	assert.Equal(t, 6, len(patches), "aa")
}`
=== RUN   TestPatchMakeOutOfRangePanic
--- FAIL: TestPatchMakeOutOfRangePanic (0.00s)

panic: runtime error: slice bounds out of range [103:100] [recovered]
	panic: runtime error: slice bounds out of range [103:100]

goroutine 19 [running]:
testing.tRunner.func1.2({0x1d6020, 0xc0000a2738})
	/usr/go1.17/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
	/usr/go1.17/src/testing/testing.go:1212 +0x218
panic({0x1d6020, 0xc0000a2738})
	/usr/go1.17/src/runtime/panic.go:1038 +0x215
github.com/sergi/go-diff/diffmatchpatch.(*DiffMatchPatch).patchMake2(0xc000093ed0, {0x1f6c06, 0x0}, {0xc00011c500, 0x8, 0x10})

	/go-diff/diffmatchpatch/patch.go:171 +0xa69
github.com/sergi/go-diff/diffmatchpatch.(*DiffMatchPatch).PatchMake(0xc000093ed0, {0xc000093e38, 0xb, 0x1a})
	/diffmatchpatch/patch.go:131 +0x1bc
github.com/sergi/go-diff/diffmatchpatch.(*DiffMatchPatch).PatchMake(0xe6393, {0xc000049f40, 0x24e39b, 0xf})
	/go-diff/diffmatchpatch/patch.go:129 +0x33b
github.com/sergi/go-diff/diffmatchpatch.TestPatchMakeOutOfRangePanic(0x0)
	/go-diff/diffmatchpatch/patch_test.go:362 +0x12a
testing.tRunner(0xc000085ba0, 0x1fc6b0)
	/usr/go1.17/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
	/usr/go1.17/src/testing/testing.go:1306 +0x35a


Process finished with the exit code 1
@vbonthaCW
Copy link

Any latest developments on this issue?

@pwnetrationguru
Copy link

Yah, I'm getting a similar error in this function:

func (dmp *DiffMatchPatch) DiffCharsToLines(diffs []Diff, lineArray []string) []Diff {

User
panic: runtime error: index out of range [65533] with length 65192

goroutine 1 [running]:
github.com/sergi/go-diff/diffmatchpatch.(*DiffMatchPatch).DiffCharsToLines(0x1400be1c2c8?, {0x1400b52c800, 0x27, 0x22000?}, {0x140126d6000, 0xfea8, 0x22000?})
        /Users/omerta/go/pkg/mod/github.com/sergi/[email protected]/diffmatchpatch/diff.go:452 +0x240
github.com/go-git/go-git/v5/utils/diff.DoWithTimeout({0x14024ede000?, 0x100c4b840?}, {0x14025490000?, 0x1009cebcc?}, 0x14006abbbd0?)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/utils/diff/diff.go:37 +0xe4
github.com/go-git/go-git/v5/utils/diff.Do(...)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/utils/diff/diff.go:22
github.com/go-git/go-git/v5/plumbing/object.filePatchWithContext({0x100f9d9c0, 0x1012a37c0}, 0x14000199f00)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/patch.go:68 +0x140
github.com/go-git/go-git/v5/plumbing/object.getPatchContext({0x100f9d9c0, 0x1012a37c0}, {0x0, 0x0}, {0x14000125e18, 0x3, 0x100f9f460?})
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/patch.go:38 +0xc4
github.com/go-git/go-git/v5/plumbing/object.Changes.PatchContext(...)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/change.go:158
github.com/go-git/go-git/v5/plumbing/object.(*Tree).PatchContext(0x34bdbbd1b9a656cc?, {0x100f9d9c0, 0x1012a37c0}, 0x101766d18?)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/tree.go:339 +0x7c
github.com/go-git/go-git/v5/plumbing/object.(*Commit).StatsContext(0x14000000900, {0x100f9d9c0, 0x1012a37c0})
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/commit.go:393 +0x1a0
github.com/go-git/go-git/v5/plumbing/object.(*Commit).Stats(...)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/commit.go:369
github.com/devzero-inc/dora/backend/processing.ParseGitRepo.func1(0x14000000900)
        /Users/omerta/playground/code/dora/backend/processing/github.go:220 +0x328
github.com/go-git/go-git/v5/plumbing/object.(*commitPreIterator).ForEach(0x140002a2d80?, 0x14000c4a330)
        /Users/omerta/go/pkg/mod/github.com/go-git/go-git/[email protected]/plumbing/object/commit_walker.go:105 +0x80
github.com/devzero-inc/dora/backend/processing.ParseGitRepo({0x14017fbe140?, 0x1400011a020?}, 0x14000a106e0, 0x4daf)
        /Users/omerta/playground/code/dora/backend/processing/github.go:186 +0x240
github.com/devzero-inc/dora/backend/processing.ProcessGithubRepo({0x100f9d9c0?, 0x1012a37c0?}, {0x100da430a, 0xa}, {0x100da2bb7, 0x6}, {0x100da303f, 0x7}, {0x100db654f, 0x28}, ...)
        /Users/omerta/playground/code/dora/backend/processing/github.go:271 +0x4e4
main.main()
        /Users/omerta/playground/code/dora/backend/scripts/generate_dora_db.go:200 +0xd78

Seems oddly close to a max int16, but that doesn't really make sense with Golang AFAICT (always 32 or 64bit).

I see last commit to repo was 8 months ago -- is this still actively being maintained?

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

Successfully merging a pull request may close this issue.

3 participants