From a sample of 84 local barred, moderately inclined disc galaxies, we determine the fraction which host boxy or peanut-shaped (B/P) bulges (the vertically thickened inner parts of bars). We find that the frequency of B/P bulges in barred galaxies is a very strong function of stellar mass: 79% of the bars in galaxies with log (M /M ) 10.4 have B/P bulges, while only 12% of those in lower-mass galaxies do. (We find a similar dependence in data published by Yoshino & Yamauchi 2015 for edge-on galaxies.) There are also strong trends with other galaxy parameters -e.g., Hubble type: 77% of S0-Sbc bars, but only 15% of Sc-Sd bars, have B/P bulges -but these appear to be side effects of the correlations of these parameters with stellar mass. In particular, despite indications from models that a high gas content can suppress bar buckling, we find no evidence that the (atomic) gas mass ratio M H +He /M affects the presence of B/P bulges, once the stellar-mass dependence is controlled for.The semi-major axes of B/P bulges range from one-quarter to three-quarters of the full bar size, with a mean of R box /L bar = 0.42 ± 0.09 and R box /a = 0.53 ± 0.12 (where R box is the size of the B/P bulge and a and L bar are lower and upper limits on the size of the bar).