The .40 cal Glocks do indeed have an issue with rail mounted lights like the X200/X300.

If there's a 100% guaranteed solution, I'm unaware of it. (Then again, I am unaware of a lot of things in this world...) To the best of my knowledge a number of different solutions have been tried from different mag springs to different recoil springs and different ammo in an attempt to solve the problem but some folks still had problems after trying those fixes.