static analyzers for detecting fatal sw errors before testing 제 3 세부과제
DESCRIPTION
Static Analyzers for Detecting Fatal SW Errors Before Testing 제 3 세부과제. 이광근 교수 Programming Research Lab. Seoul National University 1/16/2007 @ COEX. Content. Technology: Static Program Analysis Prototypes: Airac5, Umirac, Stan Commercialization: Sparrow 1.0. Open Problem. - PowerPoint PPT PresentationTRANSCRIPT
Static Analyzers for Detecting Fatal SW
Errors Before Testing
제 3 세부과제
이광근 교수
Programming Research Lab.Seoul National University
1/16/2007 @ COEX
Content
Technology: Static Program Analysis Prototypes: Airac5, Umirac, Stan Commercialization: Sparrow 1.0
Open Problem
소프트웨어가 실행되기 전에 우리가 바라는대로 실행될 지를
no core dump/segmentation fault no buffer overrun no memory leak “x.s > 0 at line 321” “notNull(y) whenever x = 0” etc.
엄밀하게 미리 확인해주는 기술은 ?
Static Program Analysis
프로그램의 실행 내용을실행전에 자동으로안전하게 어림잡는
일반적인 기술
“static analysis” “ 정적분석” “프로그램분석”
테스트와 다른점
테스트는 SW 를 실행시킬 수 있을 때 까지 기다려야
테스트는 찾고자 하는 오류를 모두 찾을 수 없음
프로그램 분석기 (static program analyzer) 는 SW 를 실행시키지 않고 타겟 오류의 위치를
자동으로 찾아줌 SW 의 소스만 준비되면 됨
Limitation: 허위 경보 (false alarm)
inevitable repeat if E then x = x+1 else x = x-1 until B
rule of the game minimize false alarms no (few) undetected errors with a reasonable cost
errors
Airac5 (Sparrow)
Statically Detecting Buffer-Overrun Errors in C Programs
int *c = (int *)malloc(sizeof(int)*10); c[i] = 1; c[i + f()] = 1; c[*k + (*g)()] = 1; x = c+5; x[1] = 1; z->a = c; (z->a)[i] = 1; foo(c+2); int foo(int *d) {… d[i] = 1; …}
Sparrow 성능
On a Linux 2.6 box with Pentium4 3.2GHz, 4GB RAM
Buffer Overrun
GNU SoftwareAlarm
sReal Errors LOC Time (sec)
tar-1.13 17 1 49,581 63
sed-4.0.8
0 0 26,807 32
hanterm-3.1.6
39 34 25,518 103
grep-2.5.1a
2 0 31,160 43
tcl-8.4.14 16 0 215,674 720
netsmp-5.4 28 0 344,005 1,147
Umirac
Statically Detecting Unused Memory Areas in C Programsvoid sigandsets(sigset_t *r, const sigset_t *a, const sigset_t *b){
unsigned long a0, a1, a2, a3, b0, b1, b2, b3;switch ((64 / 32)){case 4:
a3 = a->sig[3]; a2 = a->sig[2]; b3 = b->sig[3]; b2 = b->sig[2];r->sig[3] = ((a3) & (b3)); r->sig[2] = ((a2) & (b2));
case 2:a1 = a->sig[1]; b1 = b->sig[1]; r->sig[1] = ((a1) & (b1));
case 1: a0 = a->sig[0]; b0 = b->sig[0]; r->sig[0] = ((a0) & (b0));break;
default: _NSIG_WORDS_is_unsupported_size();}
}
Linux-2.6.4/include/asm/signal.h:22:1Target buffer size: {[4,4]}, Unused intervals: {[2,3]}
22: typedef struct {unsigned long sig[4];} sigset_t;
Umirac 성능
Software(LOC)
#alarms (#false alarms)Time(sec)UV UF BB
AviReader.c (1,486) 5(0) 0(0) 6(3) 4
H263FRDivx.c (3,944) 7(0) 2(0) 5(0) 257
software1 (4,725) 7(0) 1(0) 8(0) 291
software2 (21,653) 16(2) 2(0) 30(10) 3,948
vmax301.c (8,213) 31(8) 2(2) 1(1) 82
cdc_acm.c (12,286) 48(12) 4(3) 4(3) 139
atkbd.c (11,128) 40(7) 3(3) 3(2) 268
eata_pio.c (15,585) 105(21) 6(5) 11(6) 803
False Alarm(%)
25.36
UV: unused variables UF: unused fields BB: buffer bubble
Stan
Statically Estimating Stack Size Increment for Each Call Edge
main
simulate
compile
transduce
backtrace
reset
setup
prepare
16
3220
8
12
4
82
168
16
16
Stan 성능 함수 포인터 분석 후 call graph 생성 call 마다 최대 스택 사용량 분석
X264 분석 결과 :
Come Visit Our Booth
Demo: Umirac, Stan Product Demo: Sparrow 1.0 Talk to us and our sales reps
감사합니다
Programming Research Laboratory
Seoul National University
Sparrow 1.0
SW 오류 검증 기술의 진화
1990s 2000
s
1980
s
효용
및
성숙도
2010
s
테스트기술
정적분석기
술coverity.compolyspace.com
Sparrow 1.0
Sparrow 1.0
타겟 소스언어 C, C++ ANSI C, GNU C, G++, MS C/C++, ARM C, etc.
타겟 오류 buffer overrun memory leak uninitialized access null dereference
Other Players coverity.com
Stanford U., 미국시장에서 활발 , ’05 국내 진출시도 polyspace.com
Ecole Polytech., 유럽시장에서 활발 , ’06 국내 진출시도 grammatech.com
U. of Wisconsin-Madison, 미국정부시장 기타 ( 분석기술 미흡 : “shallow” analysis)
fortify, klocwork, secure, seque, wily 기존의 runtime tools
상용 PurifyPlus, Parasoft Insure++, Trace32, WinDBG, …
공개 SW Valgrind …
Sparrow 성능 1/2
GNU SoftwareAlarm
sReal Errors LOC Time (sec)
tar-1.13 17 1 49,581 63
sed-4.0.8
0 0 26,807 32
hanterm-3.1.6
39 34 25,518 103
grep-2.5.1a
2 0 31,160 43
tcl-8.4.14 16 0 215,674 720
netsmp-5.4 28 0 344,005 1,147
On a Linux 2.6 box with Pentium4 3.2GHz, 4GB RAM
Buffer Overrun
Sparrow 성능 2/2
GNU Software
Alarms
Real Errors LOC Time (sec)
tar-1.13 5 3 49,581 40
bison-2.3 6 1 42,581 46
sed-4.08 5 2 26,807 4
grep-2.5.1a
5 0 31,160 7
openSSH-4.3p2
16 7 77,329 51
net-snmp-5.4 95 40 344,005 533
On a Linux 2.6 box with Pentium4 3.2GHz, 4GB RAM
Memory Leaks
Sparrow beats Prevent for
deep call chain function pointers function argument loop induction variables C standard library – memcpy, memset, …
Buffer Overrun
11
36
20True
False
Sparrow beats Prevent for
arbitrary pointer aliasing alloc/free complex data structure linking argument pointers infinite loop recursion
Memory Leaks
12
16
7 3
2
True
False