Learning how to listen: Automatically finding bug patterns in event-driven JavaScript APIs

07/29/2021
by   Ellen Arteca, et al.
0

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 correctly 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 unusual patterns, which often indicate incorrect API usage. From a large-scale evaluation on 127,531 open-source JavaScript code bases, our technique was able to detect 75 incorrect listener-registration patterns, while maintaining a precision of 90.9 validation set, demonstrating that a learning-based approach to detecting event-handling bugs 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.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
04/30/2018

DeepBugs: A Learning Approach to Name-based Bug Detection

Natural language elements in source code, e.g., the names of variables a...
research
06/14/2023

A statistical approach for finding property-access errors

We study the problem of finding incorrect property accesses in JavaScrip...
research
10/28/2019

Precise Dataflow Analysis of Event-Driven Applications

Event-driven programming is widely used for implementing user interfaces...
research
08/05/2021

HIPPODROME: Data Race Repair using Static Analysis Summaries

Implementing bug-free concurrent programs is a challenging task in moder...
research
04/03/2022

A Study of Single Statement Bugs Involving Dynamic Language Features

Dynamic language features are widely available in programming languages ...
research
01/03/2018

How Does Bug-Handling Effort Differ Among Different Programming Languages?

Handling bugs is an essential part of software development. The impact o...
research
11/28/2019

Using Distributed Representation of Code for Bug Detection

Recent advances in neural modeling for bug detection have been very prom...

Please sign up or login with your details

Forgot password? Click here to reset