I was heating a flask containing salicylic acid, acetic anhydride, and H2SO4 to synthesize aspirin. During the heating period, a black sludge appeared at the bottom of the flask. I have no idea what this could be. Other students had experiments that worked just fine so there is nothing wrong with the reagents. What could this be?

It's a guess on my part but I suspect you used concd H2SO4 and that dehydrated something which left carbon as the black sludge. A second scenario is that the flask was dirty at the beginning of the experiment.