Prevalence of Confusing Code in Software Projects
Atoms of Confusion in the Wild
Dan Gopstein NYU
Hongwei Henry Zhou, Phyllis Frankl, Justin Cappos AtomsOfConfusion.com
1
Prevalence of Confusing Code in Software Projects Atoms of - - PowerPoint PPT Presentation
Prevalence of Confusing Code in Software Projects Atoms of Confusion in the Wild Dan Gopstein NYU Hongwei Henry Zhou, Phyllis Frankl, Justin Cappos AtomsOfConfusion.com 1 Atoms of Confusion in the Wild if ((err =
Hongwei Henry Zhou, Phyllis Frankl, Justin Cappos AtomsOfConfusion.com
1
2
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail;
3
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail;
4
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail;
5
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) { goto fail; goto fail;
{ }
6
7
8
9
10
11
12
13
14
15
16
Understanding Misunderstandings in Source Code
Cappos ESEC/FSE 2017
Logic as Control Flow
Pre-Increment
Literal Encoding
Operator Precedence φ = .63 φ = .48 φ = .28 φ = .33
17
18
19
20
21
1 atom every ~12 lines 1 atom every ~44 lines
22
1 every ~51 lines 1 every ~1.6 million
23
24
ulpmc->cmd = htobe32(V_ULPTX_CMD(ULP_TX_MEM_WRITE) | is_t4(sc) ? F_ULP_MEMIO_ORDER : F_T5_ULP_MEMIO_IMM);
25
https://github.com/freebsd/freebsd/blob/3c60e22da7d4460db7adb2b916f55e22b7d60e26/sys/dev/cxgbe/tom/t4_ddp.c#L766
ulpmc->cmd = htobe32(V_ULPTX_CMD(ULP_TX_MEM_WRITE) | is_t4(sc) ? F_ULP_MEMIO_ORDER : F_T5_ULP_MEMIO_IMM);
26
https://github.com/freebsd/freebsd/blob/3c60e22da7d4460db7adb2b916f55e22b7d60e26/sys/dev/cxgbe/tom/t4_ddp.c#L766
ulpmc->cmd = htobe32(V_ULPTX_CMD(ULP_TX_MEM_WRITE) | is_t4(sc) ? F_ULP_MEMIO_ORDER : F_T5_ULP_MEMIO_IMM);
27
https://github.com/freebsd/freebsd/blob/3c60e22da7d4460db7adb2b916f55e22b7d60e26/sys/dev/cxgbe/tom/t4_ddp.c#L766
28
29
30
31
1.00
32
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
33
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
34
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
35
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
36
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
37
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
38
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
39
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
40
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
41
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
42
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
43
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
44
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
45
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
46
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
47
https://github.com/torvalds/linux/commit/7aa92c4229fefff0cab6930cf977f4a0e3e606d8
48
49
○ Atoms are statistically more confusing than other code in the lab ○ Atoms are 13% more likely to be commented than other code
○ We found millions of examples in our corpus ○ 1 in ~23 lines of code has an atom
○ Bug-fix commits are 25% more likely remove atoms ○ We found and fixed a handful of bugs in Linux
Hongwei Henry Zhou, Phyllis Frankl, Justin Cappos AtomsOfConfusion.com
50