Finding and fixing a bug in VSCode

In this lab, we were tasked with finding a good beginner bug inside of VSCode to practice detecting bugs within a large framework that we're unfamiliar with. Here are the steps I followed, described in the form of these following questions;

1- Which bug(s) did you work on?

I worked on the following issue; https://github.com/Microsoft/vscode/issues/43302

2- What was this bug about? How do you make it happen (steps to reproduce)?

This bug involves Windows OS which allowed me to select it as the bug I would work on. It has to do with opening a batch file using the "Open with Code" option in a Windows explorer window. The steps to reproduce are as follows;

- Right-click on a Windows bat file in the explorer (unpacked from downloaded zip file)
- Select "Open with Code" (with the VSCode icon beside the text)
- "Windows protected your PC" screen appears to "preventing unrecognized app from starting"

First of all, I created a small bat file for testing purposes, and inserted a bit of scripting code onto it so I would make sure it had something to run if it ended up being executed on.

Secondly, I right clicked my bat file and selected the "Open with Code" option. This opened the file in the VSCode editor, behaving exactly like the expected behaviour. I then tried packing the bat file in a zip folder, moving it to another folder, unzipping it, and selected the "Open with Code" option once more. This resulted in expected behaviour again, as the file opened in VSCode editor.

I will talk about what I did next in the following steps.

3- What did you do to try and track down the cause? How close did you get?

Since I needed to find out why the bug wasn't being recreated, I used the Chrome Extension tool to try and break down where a file gets opened in VSCode from the front page, even though I know the bug occurs when you open it from outside VSCode. My goal was to find a piece of code that has the interaction between VSCode and an exterior file being opened. Using the tool, I was able to narrow down to the "Open Folder" and "New File" buttons from the welcome panel, and I searched the code by putting breakpoints and looking through to find what I was looking for. I put multiple breakpoints around the "Open Folder" functionality especially, but I couldn't get it to stop while doing the action; it would load up the folder in the VSCode window all the time. The one thing I found out about was that it is calling "command:workbench.action.files.openFolder"
4- What tools, techniques, approaches did you take when researching? What worked well, what didn't?

I used the Chrome Extension tool which was very helpful for pinpointing where the action occurs and where the calls are being made. It allowed me to narrow down to where I wanted to see actions being done, which led me to the command line I mentioned above. In terms of approaches, I thought about approaching the problem from a different entry point to reach the part of code that had to do with opening files, because the bug originally occurs from opening a file outside VSCode, but to me, reproducing it via that way would've made it a lot harder to find out where the VSCode for opening files would be executed. I would still be interested in knowing what other approaches would've yielded better results than the ones I got.
5- Were you able to do a fix? What did you change? did it work for all cases, or was it just a start?

I was not able to fix it, but it's not exactly because I couldn't find a solution, it's more a continuation of what I was working on. After I found out the command call from using the Google Extension tool, I reviewed the issue on GitHub to try and find more clues, and while re-reading the steps to reproduce, I noticed only now that the mention of the OS version and VSCode version was also added to the steps to reproduce. After double checking both of them, I realized I had the correct Windows OS version to match the user who posted the issue, however, I did not have the correct VSCode version as he had 1.19.3, and I have 1.21.0. This leads me to believe that the reason why I was not able to reproduce the bug on my end is because my version doesn't match.
6- What did you learn while doing this? What kinds of things did you notice in the code that were surprising or new to you?

As mentioned in the previous step, I realized my mistake was made before I started debugging, since I was trying to reproduce a bug on a different set of steps (wrong VSCode version). I learned to take every single bit of details posted in an issue and make sure to thoroughly understand the problem before attempting to solve it. On the side of debugging, I learned how useful the Chrome Extension Tool is in this context, as it allows you to pinpoint where the actions take place, and due to its versatility, I believe this tool can be useful for almost any issue that has to do with VSCode.

Comments

Popular posts from this blog

DPS909 Release 02: My First Open Source Contribution Part 1

DPS909 Release 03: My Second Open Source Contribution

Running Test Suites and playing with ECMA Standards