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

AI-generated keywords: Event-driven programming JavaScript Static Analysis Learning-based approach Event-handling bugs

AI-generated Key Points

  • Event-driven programming is widely used in the JavaScript community for handling UI events and AJAX requests.
  • Previous work by Madsen et al. presented a static analysis for detecting issues with event-driven programming, but it was not scalable.
  • This study proposes a learning-based approach to address the problem of detecting dead listeners.
  • The technique involves mining a large corpus of JavaScript code using static analysis to identify code snippets that register event listeners and then applying statistical modeling to identify anomalous patterns.
  • The technique was evaluated on 127,531 open-source JavaScript code bases and successfully detected 75 anomalous listener-registration patterns with a precision of 90.9% and recall of 7.5%.
  • In an additional experiment on 25 open-source projects, 30 issues were reported to project maintainers, with 7 confirmed as bugs.
  • A qualitative study was conducted on finding bugs in open-source projects by examining occurrences of listener-registration pairs classified as anomalous by the statistical analysis and manually analyzing the corresponding code snippets.
  • The ease of determining whether a listener registration is actually a bug depends on the complexity of the access path.
  • For complex access paths involving interprocedural flow, it may be challenging to determine emitted events accurately; however developers can leverage known reasons for false positives such as explicit emission checks or type checks before registering listeners.
  • Very long access paths (defined as having at least five property reads, method calls, or function parameters separating them from the initial package import) were excluded from the experiment due to their time-intensive and complicated nature for manual analysis.
  • Overall, this research demonstrates that a learning-based approach can effectively detect event-handling bugs in JavaScript code and provides valuable insights for improving API usage in event-driven programming scenarios.
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

Authors: Ellen Arteca, Max Schäfer, Frank Tip

19 pages, 6 figures. Accepted and to appear in IEEE TSE
License: CC BY-SA 4.0

Abstract: 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 anomalous 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 anomalous listener-registration patterns, while maintaining a precision of 90.9% and recall of 7.5% over our 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.

Submitted to arXiv on 29 Jul. 2021

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2107.13708v3

Event-driven programming is widely used in the JavaScript community for handling UI events and AJAX requests. However, this approach can lead to issues such as lost events or dead listeners. Previous work by Madsen et al. presented a static analysis for detecting these problems, but it was not scalable due to exponential context requirements. To address the problem of detecting dead listeners, this study proposes a learning-based approach. It involves mining a large corpus of JavaScript code using static analysis to identify code snippets that register event listeners and then applying statistical modeling to identify anomalous patterns that indicate incorrect API usage. The technique was evaluated on 127,531 open-source JavaScript code bases and successfully detected 75 anomalous listener-registration patterns with a precision of 90.9% and recall of 7.5%. In an additional experiment on 25 open-source projects, 30 issues were reported to project maintainers, with 7 confirmed as bugs. To assess the usefulness of the approach, a qualitative study was conducted on finding bugs in open-source projects. The researchers examined 100 occurrences of listener-registration pairs classified as anomalous by the statistical analysis and manually analyzed the corresponding code snippets. The ease of determining whether a listener registration is actually a bug depends on the complexity of the access path. For complex access paths involving interprocedural flow, it may be challenging to determine emitted events accurately; however developers can leverage known reasons for false positives such as explicit emission checks or type checks before registering listeners. For very long access paths (defined as having at least five property reads, method calls, or function parameters separating them from the initial package import), manual analysis would be time intensive and complicated to explain to developers; therefore these cases were excluded from the experiment. Overall, this research demonstrates that a learning-based approach can effectively detect event-handling bugs in JavaScript code and provides valuable insights for improving API usage in event-driven programming scenarios.
Created on 30 Aug. 2023

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Look for similar papers (in beta version)

By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.