Mugshot: Deterministic Capture and Replay for Javascript Applications James Mickens, Jeremy Elson, and Jon Howell Microsoft Research Mickens,Jelson,[email protected]

Mugshot: Deterministic Capture and Replay for Javascript Applications James Mickens, Jeremy Elson, and Jon Howell Microsoft Research Mickens,Jelson,Jonh@Microsoft.Com

Mugshot: Deterministic Capture and Replay for JavaScript Applications James Mickens, Jeremy Elson, and Jon Howell Microsoft Research mickens,jelson,[email protected] Abstract Perhaps the best known example is the Windows Error Reporting framework, which has collected over a billion Mugshot is a system that captures every event in an ex- error reports from user programs and the kernel [14]. ecuting JavaScript program, allowing developers to de- Unfortunately, isolated snapshots only tell part of the terministically replay past executions of web applica- story. The root cause of a bug is often difficult to deter- tions. Replay is useful for a variety of reasons: failure mine based solely on the program’s state after a problem analysis using debugging tools, performance evaluation, was detected. Accurate diagnosis often hinges on an un- and even usability analysis of a GUI. Because Mugshot derstanding of the events that preceded the failure. For can replay every execution step that led to a failure, it is this reason, systems like Flight Data Recorder [29], De- far more useful for performing root-cause analysis than jaVu [5], and liblog [13] have implemented deterministic today’s commonly deployed client-based error reporting program replay. These frameworks log enough informa- systems—core dumps and stack traces can only give de- tion about a program’s execution to replay it later un- velopers a snapshot of the system after a failure has oc- der the watchful eye of a debugging tool. With a few curred. notable exceptions, these systems require a specially in- Many logging systems require a specially instru- strumented execution environment like a custom kernel mented execution environment like a virtual machine or to capture a program’s execution. This makes them un- a custom program interpreter. In contrast, Mugshot’s suitable for field deployment to unmodified end-user ma- client-side component is implemented entirely in stan- chines. Furthermore, no existing capture and replay sys- dard JavaScript, providing event capture on unmodified tem is specifically targeted for the unique needs of the client browsers. Mugshot imposes low overhead in terms web environment. of storage (20-80KB/minute) and computation (slow- downs of about 7% for games with high event rates). Mugshot’s goal is to provide low-overhead, “always- This combination of features—a low-overhead library on” capture and replay for web-deployed JavaScript pro- that runs in unmodified browers—makes Mugshot one grams. Our key insight is that JavaScript provides of the first capture systems that is practical to deploy to sufficient reflection capabilities to log client-side non- every client and run in the common case. With Mugshot, determinism in standard JavaScript running on unmod- developers can collect widespread traces from programs ified browsers. As a user interacts with an application, in the field, gaining a visibility into application execution Mugshot’s JavaScript library logs explicit user activity that is typically only available in a controlled develop- like mouse clicks and “behind-the-scenes” activity like ment environment. the firing of timer callbacks and random number gener- ation. When the application fetches external objects like images, a server-side Mugshot proxy stores the binary 1 Introduction data so that at replay-time, requests for the objects can access the log-time versions. Despite developers’ best efforts to release high qual- The client-side Mugshot log is sent to the devel- ity code, deployed software inevitably contains bugs. oper in response to a trigger like an unexpected ex- When failures are encountered in the field, many pro- ception being caught. Once the developer has the log, grams record their state at the point of failure, e.g., in he uses Mugshot’s replay mode to recreate the original the form of a core dump, stack trace, or error log. That JavaScript execution on his unmodified browser. Like snapshot is then sent back to the developers for analysis. the logging library, the replay driver is implemented in 1 standard JavaScript. The driver provides a “VCR” in- Capture and Replay terface which allows the execution to be run in near-real time, paused, or advanced one event at a time. The in- As described by the survey papers [8] and [10], de- ternal state of the replaying application can be inspected terministic replay has been studied for many years in using unmodified JavaScript debugging tools like Fire- a variety of contexts. Some of the prior systems are bug [17]. Developers can also analyze a script’s perfor- machine-wide replay frameworks intended to debug op- mance or evaluate the usability of a graphical interface erating systems or cache coherence in distributed shared by examining how real end-users interacted with it. memory systems [11, 22, 29]. They create high-fidelity At first glance, Mugshot’s logging and replay capabil- execution logs, but with significant cost: the target soft- ities may seem to introduce a fundamentally new threat ware must run atop custom hardware, a modified kernel, to user privacy. However, Mugshot does not create new or a special virtual machine. This limits opportunities techniques for logging previously untrackable events— for widespread deployment. Furthermore, these systems instead, it leverages the preexisting introspective capa- produce log data at a high rate; generally, these systems bilities found in browsers’ standard JavaScript engines. can only report the last few seconds of system state be- Furthermore, the preexisting security policies which pre- fore an error. vent cross-site data exchange also prevent Mugshot’s Moving up the stack, a number of application- or event logs from leaking across domains. Thus, the language-specific tools allow deterministic capture and Mugshot log for a particular page can only be accessed replay. By restricting themselves to high-level interfaces by that page’s domain. and a single-threaded execution model, they obviate the The rest of the paper is organized as follows. In Sec- need to log data at the instruction level. This dramati- tion 2, we review related work in capture and replay. We cally reduces the overhead of logging, both in processor then describe the architecture of Mugshot in Section 3. time and storage requirements. The liblog system[13] Section 4 contains our evaluation, which describes mi- is perhaps closest to our work. liblog provides a C- crobenchmarks (x4.1) and Mugshot’s performance in- library interposition layer that records the input and out- side several complex, real-world applications (x4.2). Our put of all interactions between the application and the C evaluation shows that Mugshot is unobtrusive at logging library (and hence, the operating system) below. As with time and faithful at replay time, recreating several bugs Mugshot, one of liblog’s goals was to make logging suffi- that we found in our evaluation applications. We con- ciently lightweight that it can be run in the common case. sider the privacy implications of Mugshot in Section 5 Other application-specific logging environments include and then conclude in Section 6. DejaVu [5] for Java programs and Retrospect [3] for par- allel programs written using the MPI interface. Ripley [20] is a framework for preserving the compu- 2 Related Work tational integrity of AJAX applications. Client and server code is written in .NET, but Ripley automatically trans- Error Reporting from the Field lates the client-side portion into JavaScript for execution in a browser. The instrumented JavaScript sends an event There are many frameworks for collecting information stream to the web server, which replays the events to a about crashed programs and sending the data back to the server-side replica of the client. The server only executes developers. Perhaps the best known is Windows Error a client RPC if it is also generated by the replica. Reporting (WER), which has been included in Windows Mugshot differs from Ripley in three important ways. since 1999 and has collected billions of error reports First, Mugshot works on arbitrary JavaScript applica- [14]. When a crash, hang, installation failure, or other tions and does not require applications to be developed error is detected, WER creates a minidump. Minidumps in a special environment. Second, Ripley’s current im- are snapshots of the system’s essential state: register val- plementation does not capture all sources of nondeter- ues, thread stacks, lists of loaded modules, a portion of minism. For example, Ripley does not handle calls to the text segment surrounding the instruction pointer, and Date(). It could treat Date() as an RPC and have other information. With the user’s permission, this data the client synchronously fetch a value from the server (a is sent back to Microsoft, where it is bucketed according value which would also be fed to the server-side client to likely root-cause for later analysis. WER only records replica). However, this incurs a round trip for each time the state of the application at the moment of the crash; request, making it infeasible for applications like games developers must infer the sequence of events that led that rapidly generate events. Third, for performance rea- to it. Other deployed systems have similar capabilities sons, Ripley’s server-side client replicas are not actual and constraints, including Firefox’s Breakpad [4] and the web browsers—they are lightweight browser emulators iPhone OS [1]. that track DOM state (x3.1.3) but do not perform layout 2 or rendering. In contrast, Mugshot replays events inside approach of many other systems: recording all sources the same browser type used at logging time. This greatly of nondeterminism. If an application is run again and increases the likelihood that a buggy execution can be injected with the same nondeterministic events, the pro- recreated. gram will follow the same execution path that was ob- served at logging time.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us