Hacker News new | past | comments | ask | show | jobs | submit login
[flagged] Crash JavaScript and more (4chan.org)
13 points by mabynogy on Jan 18, 2018 | hide | past | favorite | 10 comments



You're just adding an element to an array infinitely. Of course it'll crash because you'll run out of memory to support the array.

How is this a bug? What's the expected behavior?


I expect every page to have a memory limit similar to the jvm, after which trying to push to the array would result in Error("out of memory")

Perhaps a dialog asking if we want to let the page use more, like the long running script dialog in most browsers.

The sandbox is suppose to protect us from malicious pranks, like browsers these days protect us from an endless loop of alert boxes by asking us if we want to see more, and endless loops in general with the long running terminate dialog.


Personally I'd want something more graceful like halting JS execution on the page and some sort of message...

When I was a teen I rudely tricked a friend to load an infinite alert() page, forcing them to kill their browser and lose some state. These days browsers don't let alerts block switching tabs or closing the offending tab, and with too frequent alerts you can check a box to block any more. It's better.


Chrome doesn't crash, it gives you an error page with the message "Google chrome ran out of memory while trying to display this web page"

IE11 just gives an OOM error in the console.


Expected: Runtime (browser) tries to reallocate the array; requests heap memory from the OS. OS obliges until paging file is full, then warns; browser does something graceful like halting JS on the page. System is slow from disk churning, but nothing crashes.


I mean it probably should not blow up your browser altogether.


The code in question (had to wget from the github referenced below - I'd rather not visit the domain OP posted at work):

<!DOCTYPE html><html><head><meta charset="utf-8"></head><body><script>

const a=[];

while(true) { a.push(42); }

</script></body></html>



This link will be a 404 at any given time in the future...


Yeah much like the Apple ones. I have a copy of the code though. But seriously do not play with it....




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: