Closed Bug 41586 Opened 20 years ago Closed 20 years ago

No javascript break function, bad javascript can lock up mozilla and even the entire box

Categories

(Core :: JavaScript Engine, defect, P3, critical)

defect

Tracking

()

VERIFIED DUPLICATE of bug 13350

People

(Reporter: nick255, Assigned: rogerl)

Details

Attachments

(1 file)

There should be a way to break out of an infinte loop in javascript (for 
example, some pages that do javascript user_agent detection).  Pressing 
Ctrl-Break (or similar) should immediately cause all javascript code to stop 
being executed.  Without this, it will be necessary to kill -9 netscape, or even 
to reboot if you can't telnet in to your main system.  Netscape 4.x has this 
same problem.  I am marking this as critical because it can cause hard drive 
corruption (not being able to shut down properly)

Reproducible: Always
Steps to Reproduce:
1.  Enable Javascript
2.  Go to websites that check user_agent
I'm not sure if I understand the description of the bug. How does an user_agent 
check as to do with an infinite loop? Could you re-explain the problem, and 
provide a test case if possible.

Anyway, I've setup this page that prints the user-agent and it works properly 
with Mozilla Build ID: 2000060508 on a PowerMac G3 running Mac OS 8.6.

The page is available at: http://www.sraq.qc.ca/useragent.html and it prints this 
with Mozilla: 
Netscape Mozilla/5.0 (Macintosh; N; PPC; en-US; m16) Gecko/20000605
The problem is with sites that use Javascript to get the user_agent, and then 
compare the user_agent with a list of known platforms and browsers.  If a match 
can not be found, the javascript will go into a loop, to try to detect a "valid" 
 user_agent.  The shopping page on www.ibm.com is a good example of this.  Until 
it was fixed, it would not recognize linux browsers, and so the browser would 
just hang with the script trying to get a valid OS.  With a way to ctrl-break 
out of javascript code, these loops can be broken out of, instead of telnetting 
in and using killall -9 (or just rebooting, for those without seperate 
terminals)
Think along these lines:
<script language="javascript">
while (true) {}
</script>

Try the attachment for some fun (80% cpu usage here under linux P133, and had to
kill moz).

Quick check:
Netscape 4.73 on Windows 95: hangs (no screen refreshes), but can close it (X).

IE 5 on Windows 95: shows a warning that the computer might slow down due to the
script on the page and ask whether to stop executing the script, or just
continue.

Mozilla 2000060708 on Windows 95: hangs (no screen refreshes) and have to kill
it (ctrl-alt-del).

Mozilla 2000060708 on Linux: hangs (no screen refreshes) and have to kill it.

Confirming the bug.
Status: UNCONFIRMED → NEW
Ever confirmed: true
A small amendment to my previous comment:
Netscape 4.73 on both Windows 95 and Linux: one can stop the script by clicking 
the stop button or pressing the Escape key, after which "test" gets rendered.
The stop button isn't even visible when I try it (the toolbar is just white.  
And escape doesn't work, although I haven't tried 4.73 (I don't use beta/alpha 
browsers as my main browser.

*** This bug has been marked as a duplicate of 13350 ***
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Verified dupe.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.