8

We have a question on Code Review, that when editing causes the browser to become unresponsive. And for me, it causes Firefox to say the script is unresponsive and asks if I wish to kill it:

Warning: Unresponsive script

A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue.

Script: https://cdn.sstatic.net/Js/wmd.en.js?v=00b75d767930:1

The source of the problem, diagnosed by another user, is due to using regex:


Steps to reproduce:

  1. Go this question.
  2. Click edit.
  • I really love how it's my question... sorry about the 30k chars though! But honestly, it becomes unresponsive for about 10 seconds and the 30k chars is part of the result. The script is actually quite short – Anthony Pham Dec 23 '16 at 19:35
  • Likely similar to Can't edit (a specific) post without script freezing, I submitted a suggested edit to make it stop hanging – Tim Stone Dec 23 '16 at 19:35
  • @TimStone Thanks, approved – Anthony Pham Dec 23 '16 at 19:36
2

Sorry about that.

I had about 30k chars on one line and probably caused catastrophic backtracking as seen in this answer. The accepted answer explains the cause of the intense crashing:

That (the long string) led to the parsing of the code block taking unusually long.

To prevent anymore crashing, I replaced most of the values with one ... so the string is extremely short and non-crashable. Do not worry, I will put this experience in mind when dealing with super long strings. Now the Python list looks like this:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, ... 9669, 9670, 9671, 9672, 9673, 9674, 9675, 9676, 9677, 9678, 9679, 9680]
|improve this answer|||||

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .