SPrinter: A Static Checker for Finding Smart Pointer Errors in C++ Programs
Xutong Ma, Jiwei Yan, Yaqi Li, Jun Yan and Jian Zhang
Institute of Software, Chinese Academy of Sciences
maxt@ios.ac.cn
Manual and Automated Memory Management
Manual Memory Management
Automated Memory Management (Smart Pointer)
Reasons:
RAII and Smart Pointer
Memory
Smart Pointer
Resource
Container
Dallocated
Destructed
Ownership and Smart Pointer API
p
release()
p
get()
Error Patterns
Error Patterns
Unconscious ownership transfer
1
2
1
p
Leaked ownership
Freed
OR
Forked ownership
A
A
A
A
A
Double Free
Freed
Invalid memory ownership
S
A
R
Stack Memory
Freed Memory
Type-Mismatched Memory
Implementation
AST
AST Sub-Tree
...
Reports
AST Matchers
AST Checkers
Error Patterns
Usage
Evaluation - Manual Benchmark Instances
Evaluation - Open Source Projects
Q & A
Thank you.