Software fault detection is one of the key technologies of software prognostics and health management. Through analyzing the Mechanism of Software Failure, the fault detection model based on the Hidden Markov Model (HMM) is proposed. After analyzing the composition and basic problem of HMM, reasons why HMM is adopted are presented; Secondly, the software function state HMM is constructed and training method of the model is proposed; Thirdly, the fault detection arithmetic of HMM is proposed through solution; Lastly, based on the arithmetic, an example is designed and demonstrated. The result proves the approach based on HMM is suitable for software fault detection.