RUS  ENG
Full version
JOURNALS // Proceedings of the Institute for System Programming of the RAS // Archive

Proceedings of ISP RAS, 2022 Volume 34, Issue 6, Pages 29–40 (Mi tisp736)

Improving the accuracy of static analysis by accounting for the values of class fields that can have only one constant value

V. S. Karcevab, V. N. Ignatyevcb

a Moscow Institute of Physics and Technology
b Ivannikov Institute for System Programming of the RAS
c Lomonosov Moscow State University

Abstract: The paper describes the approach for the improvement of the accuracy of general purpose static symbolic execution analysis of C# sources based on the accounting for the values of class fields that can have only one possible value. In addition, we propose the detector of forgotten readonly modifiers and unused fields, that use data collected by the main analysis. The approach and detectors were implemented as part of the industrial static analyzer SharpChecker. The main analysis is performed at the AST level to reduce time and resource costs. Collected values of the fields are used during symbolic execution phase allowing it to use concrete value instead of symbolic for the subset of class fields. As a result, we managed to noticeably improve the accuracy of some analyzers, such as UNREACHABLE_CODE (improved by 7.57%) or DEREF_OF_NULL (improved by 1.33%) and get new results in cases with forgotten readonly or unused fields. Achieved results allow to use analysis and detectors in the main branch of the SharpChecker and make it available to users. The paper considers in detail the algorithm of the detector and provides examples of results on the set of open source software.

Keywords: static analysis, C#, unused field, forgotten readonly, improving accuracy, field usage analysis, once-initialized field

DOI: 10.15514/ISPRAS-2022-34(6)-2



© Steklov Math. Inst. of RAS, 2024