Skip to content

Polygon.Area causes runtime error for some polygons #197

Open
@panmari

Description

@panmari

The newly added fuzz test in #196 surfaces an existing issue in the Area implementation for polygons. Stack trace:

      testing.go:1590: panic: runtime error: integer divide by zero
            goroutine 16 [running]:
            runtime/debug.Stack()
                C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x9b
            testing.tRunner.func1()
                C:/Program Files/Go/src/testing/testing.go:1590 +0x1c8
            panic({0x13746a0?, 0x16769d0?})
                C:/Program Files/Go/src/runtime/panic.go:770 +0x132
            github.com/golang/geo/s2.(*Loop).Vertex(...)
                PATH/Documents/repos/geo/s2/loop.go:562
            github.com/golang/geo/s2.(*Loop).surfaceIntegralFloat64(0xc000031c80?, 0x0?)
                PATH/Documents/repos/geo/s2/loop.go:1041 +0x959
            github.com/golang/geo/s2.(*Loop).Area(0xc00017a150)
                PATH/Documents/repos/geo/s2/loop.go:1192 +0x105
            github.com/golang/geo/s2.(*Polygon).Area(0xc00010db90?)
                PATH/Documents/repos/geo/s2/polygon.go:1008 +0x56
            github.com/golang/geo/s2.FuzzDecodePolygon.func1(0xc0000ac820, {0xc00001d680, 0x53, 0x60})
                PATH/Documents/repos/geo/s2/encode_fuzz_test.go:61 +0x10e
            reflect.Value.call({0x1365f20?, 0x13e0aa8?, 0x13b8dc0?}, {0x13b9a2b, 0x4}, {0xc000153920, 0x2, 0x2?})
                C:/Program Files/Go/src/reflect/value.go:596 +0xca6
            reflect.Value.Call({0x1365f20?, 0x13e0aa8?, 0x105bfad?}, {0xc000153920?, 0x13b8dc0?, 0xf?})
                C:/Program Files/Go/src/reflect/value.go:380 +0xb9
            testing.(*F).Fuzz.func1.1(0xc0000ac820?)
                C:/Program Files/Go/src/testing/fuzz.go:335 +0x325
            testing.tRunner(0xc0000ac820, 0xc00010db00)
                C:/Program Files/Go/src/testing/testing.go:1689 +0xfb
            created by testing.(*F).Fuzz.func1 in goroutine 6
                C:/Program Files/Go/src/testing/fuzz.go:322 +0x574

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions