Closed
Bug 566177
Opened 15 years ago
Closed 15 years ago
Placing an alert inside a for loop result in infinite looping
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 112298
People
(Reporter: jas, Unassigned)
Details
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0
This bug was found during simple debugging of javascript using alert statements. It happens when adding an alert statement to otherwise working code.
I have seen this bug in several contexts. When it happens, when Firefox sees the alert, it seems to do an implicit continue back to the beginning of the loop, and redisplays the alert. Alternatively, it could be that the alert function gets stuck and simply repeats itself.
My first obvious thought is that it is my code. However, using Safari immediately gets rid of the issue.
An example of the code would be something like this:
/* case sensitive check for repeated characters */
var sorted = arrPwd.sort();
for (var b=1; b < arrPwd.length; b++)
{
alert('in loop');
if ( sorted[b] == sorted[b - 1] )
{
nRepChar++;
}
}
Sometimes in Firefox, after passing through this code a few times, it gets stuck on the alert statement, although it should not, and in Safari, it never does. It seem important that the code should be executed a few times because on the first time through, it does not get stuck. The code is passed on each entry of a text field, so that is why the code is processed multiple times. At most the alert should display the number times as there are characters in the field at that point. But displaying hundreds of times for a 10-character value is clearly a problem.
In addition, removing the alert statement removes the looping. If it were an infinite loop in the code, it would simply hang at this point rather than executing as expected.
Reproducible: Sometimes
Steps to Reproduce:
1.Create some javascript that excutes onkeyup, so that there is a looping each character of a character string.
2.Enter some data in the field.
3.Observe that the alert displays for in the case of this code, for then number of characters in the string.
4. Then watch for a condition where the alert continues to appear in an infinite loop.
5. Try the web page in Safari and confirm that it does not loop.
Actual Results:
Infinite looping
Expected Results:
No infinite looping
Updated•15 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Comment 2•15 years ago
|
||
Hm, not a dupe.
Assignee: nobody → general
Status: RESOLVED → UNCONFIRMED
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Resolution: DUPLICATE → ---
Yep, but a dupe of a different bug.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago → 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•