This invention discloses a code defect analysis and
repair method and
system based on a large
language model. The method includes: receiving
crash information triggered by fuzzing or program execution, and performing
crash analysis to obtain
crash analysis results; obtaining key defect analysis information based on the
crash analysis results, and constructing structured defect analysis information based on the key defect analysis information; inputting the structured defect analysis information into a defect analysis model, and performing reasoning analysis on the code defects according to a three-round reasoning strategy to obtain defect analysis results; searching a historical repair
database based on the defect analysis results to obtain historical repair retrieval results, and inputting the defect analysis results and historical repair retrieval results into a patch generation model to generate candidate patch code; performing sandbox
verification on the candidate patch code to obtain valid patch code and patch
verification results, and outputting an analysis and repair report based on the defect analysis results, valid patch code, and patch
verification results.