Closed
Bug 535097
Opened 15 years ago
Closed 9 years ago
Infinite loop in javascript freezes firefox
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 516752
People
(Reporter: mangatmodi, Unassigned)
References
Details
(Keywords: hang)
Attachments
(4 files)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2b4) Gecko/20091124 Ant.com Toolbar 1.5 Firefox/3.6b4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2b4) Gecko/20091124 Ant.com Toolbar 1.5 Firefox/3.6b4
I accidentally created an HTML file with an Infinite loop in javascript. When I opened this file in firefox, it freezes. Firefox became non responsive and consumed 800Mb+ main memory and 50%+ CPU.
This bug is a very easy to think and I was surprised that it is still not patched !!
Reproducible: Always
Steps to Reproduce:
1. Save the html code given in addition content as an html file.
2. Open the file with firefox
Actual Results:
1. Firefox became non-responsive
2. Increased memory and cpu utilization
Expected Results:
Firefox should give some Unresponsive script alert Instead of loading that page.
<!-------SCRIPT TO TEST----------------->
<html>
<body>
<script type="text/javascript">
for (i = 0; i <= 5; )
{
document.write("The number is " + i);
document.write("<br />");
}
</script>
<p>Explanation:</p>
<p>This for loop starts with i=0.</p>
<p>As long as <b>i</b> is less than, or equal to 5, the loop will continue to run.</p>
<p>But, <b>i</b>here never increments !!</p>
</body>
</html>
Comment 1•15 years ago
|
||
Comment 2•15 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a1pre) Gecko/20091215 Minefield/3.7a1pre
Confirmed that it hangs. I see this also with older Firefox versions.
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → Trunk
yes,
Infinite looping is prevented in Internet Explorer. Try opening this file in Internet Explorer.
I think it's a major slip in firefox
Comment 4•15 years ago
|
||
I suspect that the problem here lies in the DOM code's control of the script timer, because of the required parser interaction. (If I remove the document.write calls I get the dialog as expected.)
Assignee: general → nobody
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM
Ever confirmed: true
QA Contact: general → general
This is the new test case without Document object. But the page is still freezing !!
Comment 6•15 years ago
|
||
It hangs indeed with a big hourglass and an unresponsive browser.
Comment 7•15 years ago
|
||
(In reply to comment #5)
> Created an attachment (id=417921) [details]
> This is the new test case, without Document.write
>
> This is the new test case without Document object. But the page is still
> freezing !!
This one gives me an unresponsive script dialog just fine in 3.5, as comment #4 indicated.
Comment 10•15 years ago
|
||
Comment on attachment 428067 [details]
A variation of bug 535097
I've had a discovery similar to this bug. My code spawns infinite alertboxes.
Windows stop responding.
I had to ctrl+alt+del -> taskman -> kill firefox.exe
Mem usage: 740k+
Cpu usage: 50%
Comment 11•14 years ago
|
||
Only the second testcase gave me trouble on Firefox 4.0b7 (32 bit Windows 7), but pressing escape closed the script dialog (the stop button didn't work).
Comment 12•12 years ago
|
||
Still freezes Firefox 20.x
Come on, guys, this is really common due to JSON Hijacking security work-arounds. Lots of apps set the start of a JSON response page to for(;;)
If you accidentally pull that down outside of the right client code, your entire Firefox process is frozen forever, and you have to kill off all of Firefox.
This is really embarrassing to still be in the product.
Comment 13•12 years ago
|
||
want to debug this , only thing i am new to mozilla development.Since i do not have much of an idea how do i go about this.Thanks in advance.
Updated•11 years ago
|
Assignee: nobody → general
Component: DOM → JavaScript Engine
OS: Windows XP → All
Hardware: x86 → All
Comment 14•11 years ago
|
||
IMHO, the core problem is that, slow JavaScript programs freeze not only the page, but also the whole Firefox browser, which is unacceptable.
Comment 15•11 years ago
|
||
The first testcase of bug 535097 hangs and crashes Aurora 25.0a2 (2013-08-23) on 64-bit Windows 7. firefox.exe stack from Process Explorer:
ntoskrnl.exe!KeWaitForMultipleObjects+0xc0a
ntdll.dll!RtlLeaveCriticalSection+0x26
MSVCR100.dll!wcspbrk+0x77
mozglue.dll!free+0x6be
mozglue.dll!realloc+0x33
xul.dll!NS_RegisterMemoryReporter+0x16c37
xul.dll!JSD_IsLockingAndThreadIdSupported+0x30a70
xul.dll!NS_RegisterMemoryReporter+0x16ff9
xul.dll!NS_CycleCollectorSuspect3+0x1fdcc
Toepassing: Firefox 25.0a2 (20130823004003)
Besturingssysteem: WINNT (x86-msvc)
- Add-on Compatibility Reporter 2.0.1
- BarTab 2.0 (Uitgeschakeld, Niet compatibel)
- British English Dictionary 1.19.1 (Uitgeschakeld)
- CacheViewer 0.6.3 (Uitgeschakeld, Niet compatibel)
- Compact Menu 2 4.3.1
- Copy Title 1.1 (Uitgeschakeld)
- Custom Tab Width 1.0.1
- Download Sort 2.5.8 (Uitgeschakeld)
- DownloadHelper 4.9.17
- Extension List Dumper 1.15.2
- File Title 1.4 (Uitgeschakeld)
- Firebug 1.12.0 (Uitgeschakeld)
- Flash and Video Download 1.37 (Uitgeschakeld)
- Flashblock 1.5.17
- foxiFrame basic 5.1 (Uitgeschakeld, Niet compatibel)
- FoxyProxy Standard 4.2.1 (Uitgeschakeld)
- Free Download Manager plugin 1.5.7.6 (Uitgeschakeld, Niet compatibel)
- Full Fullscreen 3.4 (Uitgeschakeld, Niet compatibel)
- Gecko Profiler 1.10.17 (Uitgeschakeld, Niet compatibel)
- InvisibleHand 3.8.28 (Uitgeschakeld)
- Live HTTP headers 0.17 (Uitgeschakeld)
- Mozilla Archive Format 2.0.9
- New Tab JumpStart 0.5a5.5.3 (Uitgeschakeld)
- Nightly Tester Tools 3.6 (Uitgeschakeld)
- RealDownloader 1.2.0 (Uitgeschakeld)
- Secure Login 1.0.3
- Session Manager 0.8.0.8
- Show the Image 0.7 (Uitgeschakeld)
- Showcase 0.9.5.10 (Uitgeschakeld)
- Silvermel and Charamel XT 1.5.5 (Uitgeschakeld)
- Tab Kit 0.6 (Uitgeschakeld, Niet compatibel)
- Test Pilot 1.2.2 (Uitgeschakeld)
xul.dll!NS_CycleCollectorSuspect3+0x100f7
Comment 16•11 years ago
|
||
This is after restarting in safe mode (disabled addons). Bug 905131 might be related.
Assignee | ||
Updated•11 years ago
|
Assignee: general → nobody
Comment 17•9 years ago
|
||
The second testcase shows a slow script dialog as expected and loads fine when you stop the script. The initial document.write test also works fine, albeit slowly, printing "The number is 0" to the page until you close the browser. Note that this was tested in nightly with e10s enabled. It might still iloop and block interaction in release channels, but that's not a regression. Given that this is totally fixed by e10s, I'm going to dup it to that bug.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•