Anonymous, there are two reasons for the voice to crack when anyone sings.
1) the overall range of the pitch for the song is higher or lower than that or the singer.
2) I am not sure what age group you belong to. In general, when a teenager reaches adulthood or if a person has not sung in that particular pitch for a long time, the voice cracks.
Best medicine for this is to sing the song as if you are doing a solo and concentrate on the piece where your voice is likely to crack. It would be better if you have a pitch recognition device such as a pitch pipe or any musical instrument so that you can recognize the pitch and the note. Try to sing the entire octave and practice.
If you are a teenager, then only practice can solve your issue with the voice.