Skip to content

Crash where winding number invariant is broken #78

@sfreilich

Description

@sfreilich

I'm trying to dig into a crash with this repro case:

TEST_F(Libtess2Test, CrashRepro) {
  AddPolyline(tess, {{{1.f, 0.854620099f},
                      {0.f, -1.f},
                      {1.f, -3.f},
                      {-0.5f, 0.f},
                      {0.301400006f, -1.f},
                      {-1.f, 0.784999669f},
                      {-1.f, 1.f},
                      {1.f, -3.f},
                      {2.15526676f, 1.f},
                      {-0.f, 0.583195567f},
                      {-1.f, -1.f},
                      {-0.f, 0.f},
                      {1.f, 0.f},
                      {-1.f, -1.f},
                      {-0.f, 1.f},
                      {0.5f, 0.265409946f},
                      {0.f, 0.f},
                      {-1.f, -0.f},
                      {1.f, 0.454741627f},
                      {-1.f, 1.f},
                      {1.f, 2.56512165f},
                      {1.f, 1.f},
                      {1.f, 1.f},
                      {0.893085241f, -0.f},
                      {1.f, 0.186138511f},
                      {-0.f, 1.f},
                      {1.f, 0.f},
                      {0.637948692f, -2.65960741f},
                      {-1.f, -0.0874727592f},
                      {0.853441715f, -1.f},
                      {1.f, 1.f},
                      {-1.f, 0.f},
                      {0.5f, -2.98471045f},
                      {-0.f, 0.f},
                      {3.f, 0.34419331f},
                      {1.f, 0.140874222f},
                      {1.f, 0.f},
                      {1.f, 2.f}}});
  EXPECT_EQ(tessTesselate(tess, TESS_WINDING_POSITIVE, TESS_POLYGONS,
                          kNumTriangleVertices, kComponentCount, nullptr),
            0);
}

This is surely a degenerate squiggle, but the size of the example and domain of the values seems very reasonable.

On fastbuild this fails with:

libtess2_test: Source/sweep.c:391: AddRightEdges: Assertion `regPrev->windingNumber - e->winding == reg->windingNumber' failed.

In opt, this crashes. I currently don't know how to get better stacktraces from Googletest in this build. Downstream under ASAN it gets a bit of a stacktrace, about something invalid happening in KillFace, but it doesn't give me a lot of insight where.

==1441441==ERROR: AddressSanitizer: ILL on unknown address 0x5b13b0b01336 (pc 0x5b13b0b01336 bp 0x7ffcbdcf1910 sp 0x7ffcbdcf1890 T0)
SCARINESS: 10 (signal)
    #0 0x5b13b0b01336 in KillFace third_party/libtess2/mesh.c:0
    #1 0x5b13b0b01336 in tessMeshConnect third_party/libtess2/mesh.c:499:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions