arrow
Return

Learning How to Listen: Automatically Finding Bug Patterns in Event-Driven JavaScript APIs

delete2023-01-01
delete2
delete
OA
AI
E
Ellen Arteca
M
Max Schäfer
F
Frank Tip *
DOI:10.1109/TSE.2022.3147975delete
deleteOriginal
deleteShare
deleteSave
Abstract

Abstract

En 中文
Event-driven programming is widely practiced in the JavaScript community, both on the client side to handle UI events and AJAX requests, and on the server side to accommodate long-running operations such as file or network I/O. Many popular event-based APIs allow event names to be specified as free-form strings without any validation, potentially leading to lost events for which no listener has been registered and dead listeners for events that are never emitted. In previous work, Madsen et al. presented a precise static analysis for detecting such problems, but their analysis does not scale because it may require a number of contexts that is exponential in the size of the program. Concentrating on the problem of detecting dead listeners, we present an approach to learn how to use event-based APIs by first mining a large corpus of JavaScript code using a simple static analysis to identify code snippets that register an event listener, and then applying statistical modeling to identify anomalous patterns, which often indicate incorrect API usage. In a large-scale evaluation on 127,531 open-source JavaScript code bases, our technique was able to detect 75 anomalous listener-registration patterns, while maintaining a precision of 90.9% and recall of 7.5% over a validation set, demonstrating that a learning-based approach to detecting event-handling bug patterns is feasible. In an additional experiment, we investigated instances of these patterns in 25 open-source projects, and reported 30 issues to the project maintainers, of which 7 have been confirmed as bugs.
Keywords:
Static analysis
Libraries
JavaScript
event-driven programming
bug finding
API modeling

Journal

IEEE Transactions on Software Engineering cover
IEEE Transactions on Software Engineering
IF:
5.6
Papers:
2.9K
Citations:
1.1W

Organization

N
Northeastern University
Scholars:
2.5W
Papers: 1.6W
Citations: 3.0W
Cited Papers

Cited Papers

Prevalence study of epilepsy in Malaysia
err2021-02-01
err0
PREAI
errSi-Lei Fong; Kheng-Seang Lim; LeeAnn Tan; Nabilah Hanis Zainuddin; Jun-Hui Ho; Zhi-Jien Chia; Wan-Yuen Choo; Santhi Datuk Puvanarajah; Suganthi Chinnasami; Sow-Kuan Tee; Azman Ali Raymond; Wan-Chung Law; Chong-Tin Tan
errShare
errSave
Toward Analysis and Bug Finding in JavaScript Web Applications in the Wild
err2019-05-01
err6
PREAI
errRyu, Sukyoung; Park, Jihyeok; Park, Joonyoung
errShare
errSave
A novel insect-infecting virga/nege-like virus group and its pervasive endogenization into insect genomes
err2019-03-01
err0
PREAI
errHideki Kondo; Sotaro Chiba; Kazuyuki Maruyama; Ida Bagus Andika; Nobuhiro Suzuki
errShare
errSave
Complementary chromosome folding by transcription factors and cohesin
err
IF0
err2018-04-23
err0
PREAI
errM. C. F. Pereira; C. A. Brackley; D. Michieletto; C. Annunziatella; S. Bianco; A. M. Chiariello; M. Nicodemi; D. Marenduzzo
errShare
errSave
T1 Bladder Tumours
err1977-12-01
err0
PREAI
errJ. L. WILLIAMS; J. C. HAMMONDS; N. SAUNDERS
errShare
errSave
Methamphetamine Causes Differential Alterations in Gene Expression and Patterns of Histone Acetylation/Hypoacetylation in the Rat Nucleus Accumbens
err2012-03-28
err0
errOAAI
errTracey A. Martin; Subramaniam Jayanthi; Michael T. McCoy; Christie Brannock; Bruce Ladenheim; Tiffany Garrett; Elin Lehrmann; Kevin G. Becker; Jean Lud Cadet
errShare
errSave
researcher View more