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

Backend fails when subslices are of different length #390

Closed
Tabaie opened this issue Oct 29, 2022 · 0 comments
Closed

Backend fails when subslices are of different length #390

Tabaie opened this issue Oct 29, 2022 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Tabaie
Copy link
Contributor

Tabaie commented Oct 29, 2022

Code provided here.

Seems like somewhere in the backend it is assumed that all multi-dimensional slices have consistent lengths. i.e. If there is a witness variable Slice [][]frontend.Variable of length at least 2, it is assumed that len(Slice[0]) == len(Slice[1]).

One of the test routines provided to check this, TestInconsistentSliceLengthProving, fails the marshal/json subtest with panic: runtime error: index out of range [3] with length 3.

testing.tRunner.func1.2({0x102d1bc00, 0x1400002c7f8})
	go/1.19/libexec/src/testing/testing.go:1396 +0x1c8
testing.tRunner.func1()
	go/1.19/libexec/src/testing/testing.go:1399 +0x378
panic({0x102d1bc00, 0x1400002c7f8})
	go/1.19/libexec/src/runtime/panic.go:884 +0x204
github.com/consensys/gnark/internal/backend/bn254/witness.(*Witness).ToAssignment.func1.1(0x14000386940?, {0x102d5d4e0?, 0x14000396538?, 0x102d28b60?})
	project-path/gnark/internal/backend/bn254/witness/witness.go:147 +0x250
github.com/consensys/gnark/frontend/schema.parse({0x0?, 0x0, 0x0}, {0x14000386940?, 0x14000396538?}, {0x102d70ae8?, 0x102d5d4e0}, {0x1400039c030, 0x9}, {0x1400039c030, ...}, ...)
	project-path/gnark/frontend/schema/schema.go:223 +0x71c
github.com/consensys/gnark/frontend/schema.parse({0x14000399440?, 0x1, 0x1}, {0x14000386900?, 0x14000396530?}, {0x102d70ae8?, 0x102d5d4e0}, {0x1400039c019, 0x7}, {0x1400039c019, ...}, ...)
	project-path/gnark/frontend/schema/schema.go:341 +0xcf4
github.com/consensys/gnark/frontend/schema.parse({0x0?, 0x0, 0x0}, {0x140003868c0?, 0x14000396520?}, {0x102d70ae8?, 0x102d5d4e0}, {0x1400032df53, 0x5}, {0x1400032df53, ...}, ...)
	project-path/gnark/frontend/schema/schema.go:363 +0xa00
github.com/consensys/gnark/frontend/schema.parse({0x0?, 0x0, 0x0}, {0x14000386880?, 0x14000396520?}, {0x102d70ae8?, 0x102d5d4e0}, {0x0, 0x0}, {0x0, ...}, ...)
	project-path/gnark/frontend/schema/schema.go:292 +0x12c8
github.com/consensys/gnark/frontend/schema.Parse({0x14000386880?, 0x14000396520?}, {0x102d70ae8?, 0x102d5d4e0?}, 0x14000398ea0?)
	project-path/gnark/frontend/schema/schema.go:52 +0x80
github.com/consensys/gnark/internal/backend/bn254/witness.(*Witness).ToAssignment(0x1400000e8b8, {0x14000386880, 0x14000396520}, {0x102d70ae8?, 0x102d5d4e0?}, 0x0)
	project-path/gnark/internal/backend/bn254/witness/witness.go:161 +0xf0
github.com/consensys/gnark/backend/witness.(*Witness).toAssignment(0x14000187fe0, {0x14000386880, 0x14000396520}, {0x102d70ae8, 0x102d5d4e0})
	project-path/gnark/backend/witness/witness.go:239 +0xf8
github.com/consensys/gnark/backend/witness.(*Witness).MarshalJSON(0x14000187fe0)
	project-path/gnark/backend/witness/witness.go:162 +0x15c
github.com/consensys/gnark/test.(*Assert).marshalWitness(0x1400000e990, 0x14000187fe0, 0x1, 0x6?, {0x102acc5ac?, 0x18?, 0x102d65080?})
	project-path/gnark/test/assert.go:540 +0x78
github.com/consensys/gnark/test.(*Assert).ProverSucceeded.func1(0x1400000e990)
	project-path/gnark/test/assert.go:107 +0x58
github.com/consensys/gnark/test.(*Assert).Run.func1(0x1400013f380)
	project-path/gnark/test/assert.go:72 +0xe8
testing.tRunner(0x1400013f380, 0x1400000e960)
	go/1.19/libexec/src/testing/testing.go:1446 +0x10c
created by testing.(*T).Run
	go/1.19/libexec/src/testing/testing.go:1493 +0x300

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