polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

Segmentation fault during shutdown on WSL

Open c-f-h opened this issue 10 months ago • 0 comments

I have this simple program:

#include <polyscope/polyscope.h>
#include <polyscope/surface_mesh.h>

int main()
{
    polyscope::init();

    std::vector<std::array<double, 3>> vertices{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}};
    std::vector<std::array<int, 3>> faces{{0, 1, 2}};
    std::vector<double> scalars{0.0, 1.0, 2.0};

    polyscope::registerSurfaceMesh("my mesh", vertices, faces);

    polyscope::getSurfaceMesh("my mesh")->addVertexScalarQuantity("my_scalar", scalars)->setEnabled(true);

    polyscope::show();
}

I'm running it on WSL, backend:

[polyscope] Backend: openGL3_glfw -- Loaded openGL version: 4.1 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.3

Polyscope is at the latest master version (except the very latest commit which breaks compilation btw).

The program runs fine, but when I close the window, I get

Segmentation fault (core dumped)

I debugged into it and the crash happens at gl_engine.cpp, in the destructor of GLTextureBuffer:

GLTextureBuffer::~GLTextureBuffer() {
   glDeleteTextures(1, &handle);
  }

The call to glDeleteTextures is still reached, and the crash seems to happen within it. I verified that handle is a reasonable-looking number (34 in my case). If I remove setEnabled(true) and don't manually enable the scalar field either, the crash goes away. Let me know if I can provide any more info to debug this...

c-f-h avatar Mar 29 '25 10:03 c-f-h