semfix: program repair via semantic analysis
DESCRIPTION
X-1. SemFix: Program Repair via Semantic Analysis. Hoang Duong Thien Nguyen † , Dawei Qi † , Abhik Roychoudhury † , Satish Chandra ‡ † School of Computing, National University of Singapore, Singapore ‡ IBM Research, USA. 紹介: 大阪大学大学院情報科学研究科 コンピュータサイエンス専攻 楠本研究室 楊 嘉晨. X-1. - PowerPoint PPT PresentationTRANSCRIPT
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
SemFix: Program Repair via Semantic
AnalysisHoang Duong Thien Nguyen†, Dawei Qi†, Abhik Roychoudhury†, Satish
Chandra‡
†School of Computing, National University of Singapore, Singapore‡IBM Research, USA
2013/7/9 1
紹介:大阪大学大学院情報科学研究科コンピュータサイエンス専攻 楠本研究室楊 嘉晨
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
既存のプログラム自動修復:GenProg
2013/7/9 2
プログラム
テストケース
…
?
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
障害の原因となるステートメントを特定
1 int is_upward_preferred( int inhibit, int up_sep, int down_sep) { 2 int bias; 3 if (inhibit) 4 bias = down_sep; 5 else 6 bias = up_sep; 7 if (bias > down_sep) 8 return 1; 9 else10 return 0;11 }
2013/7/9 3
行番号 実行 成功 失敗 スコア
ランク
4 3 1 2 0.75 1
10 4 2 2 0.6 2
3 5 3 2 0.5 3
7 5 3 2 0.5 3
6 2 2 0 0 5
8 1 1 0 0 5
入力 期待結果
実際結果
状態inhibit up_set down_sep
1 0 100 0 0 成功
1 11 110 1 0 失敗
0 100 50 1 1 成功
1 -20 60 1 0 失敗
0 0 10 0 0 成功
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
記号実行による修復案を導く
2013/7/9 4
1 int is_upward_preferred( int inhibit, int up_sep, int down_sep) { 2 int bias; 3 if (inhibit) 4 bias = X; 5 else 6 bias = up_sep; 7 if (bias > down_sep) 8 return 1; 9 else10 return 0;11 }
入力 期待結果
制約inhibit up_set down_sep
1 0 100 0
1 11 110 1
1 -20 60 1
100up_set
)down_set,up_set,inhibit(
fX
bias=up_sep+100
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
GenProg との比較実験
2013/7/9 5
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
感想☺ソースコードに存在しない修復案を自動
生成–使える計算の組み合わせが幅広い
☺実験と結果の分析がとても詳しく記述されていた– GNU Coreutils の実際にあるバグを修復し
た
☹正確さはテストケースに依存する☹1 行以上にバグがあると修復できない
2013/7/9 6
X-1
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
Automatic Recovery from Runtime Failures
Antonio Carzaniga*, Alessandra Gorlay†, Andrea Mattavelli*, and Nicolo Perino*, Mauro Pezze*
*University of Lugano, Faculty of Informatics Lugano, Switzerland†Saarland University, Computer Science, Saarbrucken, Germany
2013/7/9 7
紹介:大阪大学大学院情報科学研究科コンピュータサイエンス専攻 楠本研究室井垣 宏
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
背景と目的• バグが残ったまま Deploy されているソ
フトウェアシステムは多い–特殊な状況でしか発生しない–単体テストのみでは検出できない
• 実行時に故障発生を検知し,バグを含むプログラムを正しい実行結果を返すプログラムに変更する
2013/7/9 8
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
アプローチ• 故障を検知すると検知直前の CheckPoint に
ロールバックし,故障を検知したプログラムとは別のプログラムを実行する
2013/7/9 9
X-2
---------------------------------------------------------------------------------------------------------------------------------------------
CheckPoint
CheckPoint
---------------------------------------------------------------------------------------------------------------------------------------------
正常
異常終了
正常
異常
RollBack
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
アプローチ• 故障を検知すると検知直前の CheckPoint に
ロールバックし,故障を検知したプログラムとは別のプログラムを実行する
2013/7/9 10
X-2
---------------------------------------------------------------------------------------------------------------------------------------------
CheckPoint
CheckPoint
---------------------------------------------------------------------------------------------------------------------------------------------
正常
異常終了
正常RollBack
正常代替呼び出し
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
代替呼び出し (workaround)
• deprecated method• 出力の一部が共通であるメソッド• 前提条件が異なるが出力が等しいメソッド• -> Intrinsic Redundancy– semantically equivalent, syntactically different– -> 混入するバグが異なる
2013/7/9 11
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
実験• Real Faults in JodaTime–提案手法で実際に 3 つの Issue を検出し,代
替呼び出しと差し替えることが出来た• Mutation Analysis–エラーを生成して埋め込み,どの程度提案手
法で検知できるか(後述)• Runtime Overhead–正常時のオーバヘッド(後述)
2013/7/9 12
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory2013/7/9 13
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
感想• deprecated code の使い道として非常に興味深
い
• 古いメソッドを新しいメソッドに差し替える際に対応関係を開発者が明記しておく
• 新しいメソッドで故障が検出されたときだけ対応する古いメソッドが呼び出される–しかもこの処理が自動化されていて,古いメソッド
が呼ばれたことを開発者にフィードバックしてくれたら!
–保守に伴うコード編集が怖くなくなるかも2013/7/9 14
X-2
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
Program Transformations to Fix C Integers
Zack Coker and Munawar HafizAuburn University
2013/7/9 15
紹介:大阪大学大学院情報科学研究科コンピュータサイエンス専攻 楠本研究室村上 寛明
スライド中の図表は論文から引用しています.
X-3
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
概要• 目的– C 言語の整数に関する問題を抱えたソース
コードを自動的に修正すること.
• 貢献– C 言語の整数に関する問題の解決法(ソース
コードの修正方法)を提案した.–提案手法をツールとして実装し,公開した.
2013/7/9 16
X-3
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
提案手法• Add Integer Cast (AIC)• Replace Arithmetic Operator (RAO)• Change Integer Type (CIT)
2013/7/9 17
memcpy() の第三引数は符号なし整数として扱われるが,通常の整数として宣言されてい
る
CIT を用いたソースコードの修正例
符号なし整数として宣言するようにプログラムを自動修正する
X-3
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
評価実験• 整数における脆弱性が報告されているプログラ
ム( 7,147 個)に対し,提案手法を適用した.
2013/7/9 18
自動修正した箇所は 1,500 万行以上に及んだ
X-3
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
所感 非常に読みやすい– 難しい表現を用いていない– 図を使って提案手法を分かりやすく説明している
ツールを公開している“http://www.munawarhafiz.com/research/openrefactory-C/index.htm”
新規性は無い?– C 言語の整数についての研究は幅広く行われている
精度の評価は?– 修正した後のソースコードが正しく振る舞うのかを調査しなくてもよいのか?
2013/7/9 19
X-3
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
Automatic Patch Generation Learned from Human-Written
PatchesDongsun Kim, Jaechang Nam, Jaewoo Song, and Sunghun KimThe Hong Kong University of Science and Technology, China
2013/7/9 20
紹介:大阪大学大学院情報科学研究科コンピュータサイエンス専攻 楠本研究室堀田 圭佑
★ SIGSOFT Distinguished Paper Award 受賞論文
X-4
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
研究概要• 目的–パッチの自動生成
• 特長–人が作成したパッチをベースにしたパッチ生
成
2013/7/9 21
バグを含むコード
人が作成したパッチ
提案手法が自動生成したパッチ
Automatic Patch Generation Learned from Human-Written PatchesFig. 1 (a), (c), (d) より引用
X-4
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
提案手法: PAR
2013/7/9 22
Automatic Patch Generation Learned from Human-Written PatchesFig. 3 より引用
不具合を含んでいそうな箇所(Fault Location) を特定 [8]
[8] C. Le Goues, M. Dewey-Vogt, S. Forrest, and W. Weimer, “A systematic study of automated program repair: Fixing 55 out of 105 bugs for $8 each,” in ICSE ’12.
テストケースを用いてパッチ候補をテスト
Fault Location ( とその近傍 ) を修正したコード片 ( パッチ候補 ) を生成
通った
通らなかった
著者らが実際のパッチを分析して特定learned from human-written patches
パッチに頻出するパターン†をベースにパッチ候補を
生成
† : パラメータの追加, null-check の追加 etc.
X-4
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
評価• 既存手法 GenProg との比較–パッチ候補をランダムに作って,テストケースが
通れば OK ,という手法• Fixability– 6 つのソフトウェアから実在したバグ 119 個を収
集• バグをいくつ修正できたかを比較
• Acceptability– PAR と GenProg がともに修正できたバグについ
て,それぞれが生成したパッチを人が評価• 253人が評価
2013/7/9 23
PAR : 27 個 > GenProg : 16個
PAR の方が acceptable
X-4
Department of Computer Science, Graduate School of Information Science and Technology, Osaka University. http://sdl.ist.osaka-u.ac.jp/KUSUMOTO LABORATORY - Software Design Laboratory
貢献• パッチの分析– 62,656 のパッチを分析–パッチに頻出するパターンを見つけた
• 定量的評価– 119 個の実在のバグ• 2 つのツールを各バグにつき 100回実行
– 253人が参加した被験者実験
2013/7/9 24
X-4