5 ms·
The other day I managed to freeze my computer -- such that I did not even have access to the SysReq key, by stupidly running while (true) { var d = new Date;
by fao_ 9y ago
The other day I managed to freeze my computer -- such that I did not even have access to the SysReq key, by stupidly running
while (true) { var d = new Date; e.textContent = d.toLocaleString(); }
I immediately realised my stupidity, and closed the tab. Shortly after, my mouse froze up, then my keyboard access, and eventually my entire access. Rather than just freezing Xorg as I had initially suspected, it froze my entire computer access. No SysReq, no switching to a tty, nothing.
I was an idiot, but at the same time, an unprivileged process should not be able to consume resources like that without a dæmon coming in and pausing/killing it. And the Javascript should not have been allowed to execute once I had closed the window.
Truly, Javascript is eating the world.
- Sacho 9y agoI tried your code snippet on my inferior Windows OS and inferior IE Edge browser. The tab stopped functioning. I opened a few other tabs and continued to work. Eventually IE showed a notice that the tab had stopped responding - I had the option to close the tab or recover the webpage. I clicked 'recover webpage', the page was refreshed and I could continue using it. Truly, Javascript is eating the world. Or perhaps the language has nothing to do with your problem.
- fao_ 9y agoDo you deny that implementations are part of the language? If the Javascript specification left this out, what other implementation gotchyas exist for them to exploit?
- sk5t 9y agoFew but you likely consider the implementation part of the language.
- sweep4r 9y agoHow is CPython not a part of Python? After all all Python implementations are always, always compared to CPython
- falcolas 9y agoCount me as one of them. The implementations are what matter. They're the only thing that matters. It's the business axiom "Ideas are worthless, it's the implementation that counts" at work. Ask yourself this: If V8's performance was still at 2010 levels, would Node exist? And if some other language were the one which had been picked for browsers - JavaScript relegated to only running on servers - I wager JavaScript would hardly be used at all.
- sk5t 9y agoV8 is a good runtime implementation for a pretty weak language. Personally I don't think node's existence is a net positive for the world. Ask yourself if we'd be farther ahead if the browsers of 20 years ago ran Perl instead. Anyhow, this entire thread already supports the two ideas that (1) implementation is hugely important and (2) not all issues are language issues per se.
- fao_ 9y agoC explicitly states what an implementation should and should not do. The same with C++, FORTRAN, and other standards. Javascript is a standard written by committee. So why can't it tell implementations what is good behavior and what isn't? Other languages do.
- sk5t 9y agoI think there's a distinction to be made between the language spec (e.g., interesting Javascripty details like what is the result of `"" + 1`) and integration issues like what to do when the browser window detaches, how many threads the browser will devote to running Javascript, what to do when some of those threads appear to be blocked, or how should the runtime/VM attempt to recover from deadlock or OOM.
- deleted 9y ago[deleted]
- Jyaif 9y agoLanguage != implementation Language != compiler Language != library Language != SDK That being said, JS sucks for large projects.
- ghostbrainalpha 9y agoYou have me curious. Why would you run IE Edge instead of Chrome?
- tedunangst 9y agoEdge support for touch screens is considerably better than chrome.
- borisj 9y agoJavascript is just the language. Its your runtime environment (browser) that is letting an unprivileged process consume resources like that without killing it.
- curtisblaine 9y agoAnd it seems, his operating system allowing the browser process to take all the CPU.
- AlexeyBrin 9y agoI would argue that all modern Operating Systems have dark corners and hidden bugs. It is just a question of time until you hit a similar bug on any OS. I had a similar experience on macOS with Chrome Canary watching a YouTube movie full screen. My laptop simply froze, nothing, except a restart, worked.
- curtisblaine 9y agoPerfectly happy with the existence of OS bugs. As long as they're not used as incorrect evidence to criticize programming languages.
- whipoodle 9y agoCome on.
- TrickyRick 9y agoI would have thought that all competent browsers run tabs in unique processes.
- fao_ 9y agoThat's what I thought too. I think the process was so locked up in executing the code that it perhaps didn't respond to the kill message?