Weird gaps in mask texture painting
Uf ...


Apply Scale Ctrl+A ... fixed painting, brush skipped all parts with even minimum slope.




Since painting worked fine without Displacement modifier I was just curious why you used Strength 3000 for such contrast displace map (usually 1 is more than enough). Than I saw your Scale ratio Terrain 7500 / 4500 / 1.

If you try to set Scale 1/1/1, you can see why brush could not handle that :)
Faces are too steep in original ratio. Brush probably thinks faces are on side or squeezed in such a small place to detect or what ever. Scale ratio cause quite a lot of issues in general.



BTW - the similar extreme is use for mesh as a one face for such kind of subdivision, I would suggest subdivide id few times in edit mode (first Ctrl+R to add loopcut in a midle so subdivision faces are square, not rectangle)