Offset bug in a compute shader for particle system.

I am trying to make a particle system using compute shader. My code is heavily inspired by this repo : GitHub - MauriceGit/Partikel_accelleration_on_GPU: Particle accelleration with OpenGL 4.3, using the compute shader to calculate particle movement on graphics hardware.

My bug is that some of my particles don’t seem to be properly updated: They start at position (0, 0.5, 0) with a time to live of 2.5 and when their ttl reach 0, the compute shader should reset them at (0, 0, 0) with a ttl of 2.5 and the same velocity/direction vector. But, I have some of the particles who stay at (0, 0.5, 0) and even more strangely, seem to take into account only the X and Z component of the velocity vector (they don’t move up or down). Here is a recording of the bug: IMG 2563 GIF | Gfycat
My complete code is available here : GitHub - maeln/particles: Particles-based rendering engine. (look at src/particle_handler.cc to see everything related to the particle and data/particle.cs to see the compute shader).

I tried to dig a bit to find where the bug was coming from so I tried aligning the particle on the X axis by putting this in the compute shader

positions[id] = vec3(float(id)/128.0, 0, 0);

and I ended up with this : Hello World 17 12 2017 12 50 13 GIF | Gfycat
(particles aligned on X, Y and Z axis for those who can’t open the link).
So it definitely seems like the data is written with an offset every 32 particles.
By going a bit further, I outputted the data in the VBO after a single pass from the compute shader to see what was happening with the positions and I obtained this: (0.00000, 0.00000, 0.00000; 0) (0.00000, 0.00781, 0.00000; 1) (0.00000, 0.500 - Pastebin.com (for each particle the format is (x, y, z; id))
So it definitely seem like the compute shader is reading or writing the data with an offset, but I cannot figure out why.

I have been struggling with this bug for 2 days, so any help is appreciated !

EDIT: Here is a paste with better indentation : (0.00000, 0.00000, 0.00000; 0) (0.00000, 0.00781, 0.00000; 1) (0.00000, 0.50000, - Pastebin.com
You can clearly see whats happening: every time the compute shader run, it gain an offset of one and skip the fourth run. So you the pattern is : write X in X, X in Y, X in Z, Skip, Repeat.

I finnally found the bug: Interface Block (GLSL) - OpenGL Wiki

I was using the STD430 memory layout in my compute shader, which inherit the property of STD140. There is a warning that some implementation get padding wrong when using vec3 (which I was) to the point where using vec3 with std430/std140 is not advised. Using the memory layout “shared” or “packed” didn’t solve the problem but using

glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);

for the position VBO seem to fix the issue, but I will try to find a better way to handle this.