Formation mechanism of cavitating spalls