Crash on quit after shrinking a ParticleSystem's buffer size

Issue #1177 duplicate
Bart van Strien
created an issue

… when the new buffer is too small to contain the current number of particles.

From the forums, posted by cval here.

Something funny goes on when i'm trying to change ParticleSystem's buffer size when it has active particles in it. When i change it at runtime to a greater value than its current buffer size, or particle count (greatest value between them from math.max function), it's perfectly fine, however when i'm trying to change it to a value which is less than current particle count, or buffer size, the program runs just fine, but once i try to quit, it crashes somewhere after processing quit event (which is currently completely blank btw). Yeah, sometimes i create weird use cases that break the engine but it's fine since i can easily do without it. Idk, maybe this information will be helpful to someone who does same thing and wonders what's going on.

Comments (7)

  1. Bart van Strien reporter

    I couldn't reproduce using a simple test script (see below), I have asked cval on the forums to provide a .love.

    function love.load(args)
        local dot = love.image.newImageData(1, 1)
        dot:setPixel(0, 0, 255, 255, 255, 255)
        dot =
        ps =, 500)
        ps:setParticleLifetime(10, 20)
        for i, v in ipairs(args) do
            if v == "crash" then
                print("Shrinking buffer size to 100, current particle count: " .. ps:getCount())
                print("  new count: " .. ps:getCount())
  2. Bart van Strien reporter
    • changed status to open

    After getting a .love a while back, I've slowly been working on reducing the test case to something simpler. So far it suggests it's all love.physics' fault, and there's nothing special about ParticleSystem. In particular, when the only reference to an object (which in my tests was a ParticleSystem) is the userdata of a fixture, and love is being closed, lua seems to release the (last) reference to the ParticleSystem before calling the endContact callback, which can then use getUserData to get a reference to a ParticleSystem that has already been collected.

    As I said, I've been working on getting a minimal test case, and I will put it here once I'm sure it's minimal.

  3. Log in to comment