XMLHttpRequest isn't rooted while in flight
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 431
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
osx-test/hello-osx.js has this block:
this.xmlhttp = new XMLHttpRequest();
this.xmlhttp.onreadystatechange = () => {
console.log ("readyState == " + this.xmlhttp.readyState);
if (this.xmlhttp.readyState === 4) {
console.log ("woohoo!");
console.log (this.xmlhttp.responseText);
}
};
console.log (this.xmlhttp.onreadystatechange);
this.xmlhttp.open('GET', 'http://www.google.com/', true);
this.xmlhttp.send();
'xmlhttp' should be a local variable, but if you make it one we crash, since the .send() doesn't cause it to be rooted by the GC. The GC frees it and we crash when attempting to call the onreadystatechange callback.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the XMLHttpRequest example in osx-test/hello-osx.js and trace what happens from send() through the asynchronous onreadystatechange callback. Investigate how the runtime roots objects during an in-flight request. Done means the local XMLHttpRequest remains alive until the callback runs and the example no longer crashes after garbage collection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100