ABSTRACT We present a new definition of cosmic void and a publicly available code with the algorithm that implements it. Underdense regions are defined as free-form objects, called popcorn voids, made from the union of spheres of maximum volume with a given joint integrated underdensity contrast. The method is inspired by the excursion-set theory and consequently no rescaling processing is needed, the removal of overlapping voids and objects with sizes below the shot noise threshold is inherent in the algorithm. The abundance of popcorn voids in the matter field can be fitted using the excursion-set theory provided the relationship between the linear density contrast of the barrier and the threshold used in void identification is modified relative to the spherical evolution model. We also analysed the abundance of voids in biased tracer samples in redshift space. We show how the void abundance can be used to measure the geometric distortions due to the assumed fiducial cosmology, in a test similar to an Alcock–Paczyński test. Using the formalism derived from previous works, we show how to correct the abundance of popcorn voids for redshift-space distortion effects. Using this treatment, in combination with the excursion-set theory, we demonstrate the feasibility of void abundance measurements as cosmological probes. We obtain unbiased estimates of the target parameters, albeit with large degeneracies in the parameter space. Therefore, we conclude that the proposed test in combination with other cosmological probes has potential to improve current cosmological parameter constraints.