Sunday, January 21, 2007

Weird bug crashes Firefox totally without warning

This site uses a lot of DHTML-objects and the purpose was to make this work for IE 6/7, Firefox and Opera with the priority in that order. After months of coding and testing, I felt that this site was pretty stable, and so I asked my friends to help me test this site out.

After 2 hours I got a text message at my MSN messenger where a friend claims that my site makes his Firefox (2.01) to totaly Crash! No error message, no nothing, it just crashes and closes all Firefox windows opened. I ask what he did to make this crash and he says "I just clicked on the Find!-button twice". OMG! I immediately start trying to reproduce this bug, and find out that my Firefox also crashes, sometimes. Not every time I click the Find!-button, but every other time approximately.

Now I was forced to start dividing up my code in pieces and start commenting out code, to narrow down the bug, and as you can imagine my Firefox crashed many many many times that day and the day after.

Eventually I narrowed the bug down and found out that it was something in my main .css-file that caused Firefox to unexpectedly crash! At the end I finaly found what was causing Firefox to crash. It was a CSS-class that had "position: absolute" as an attribute and this class was used by the many DHTML objects used in my code.

I guess this error is some kind of buffer-overflow bug thats causing FF to die. So to solve this problem I had to change the actual CSS-class from absolute to static, and then later on in javascript-code, I could change the position to be absolute. And FINALY, Firefox did not crash so horribly that it had done before. So bevare developers if you experience this Firefox crash bug, try commenting out your (extensive) style-sheet.

If you have Firefox and want to test if your Firefox crashes, go here

4 comments:

Unknown said...

Hi. I am having somewhat of a similar problem, where I have a site with a bunch of absolutely-positioned elements, including iFrames, and as soon as I try to call any sort of javascript function within one of the iframes, Firefox 2.0.1 completely crashes, with no warnings or anything. I tried many things - running in safe mode, creating a new profile, etc. -- before i came across your comments. The crash occurs even if all i try to do is call an alert in the framed document. It all works fine in IE7.

My question is this: you talk about changing the css styles dynamically solving your problem. Did you have to do that for *all* absolutely-positioned elements on the page? Or was it just the one you were messing with? And how, specifically, did you implement that?

Thanks!

Mike

Mina 5 cent said...

Hi Mike.
The bug I encountered was a scary one, the fact that I did not discover it at once and that it was somewhat hard to reproduce did not make things better. In my case I narrowed it down to the CSS-propert: position: and when I set this property to absolute and created dynamicly Iframes with DIVs around them it crashed for me. My solution (at that point) was to not set the CSS-style sheet to absolute, but to do it with javascript code "later" in the page, almost at the very end of it. And to answer your question, it was not for ALL divs on the page, but a rather big range of DIVS (about 10-15). Now about 1-2 months and a lot of code change later this problem does not occur to my at all. Maybe it was due to a bad programming method from my side at that point. Hope this helps a tad.

/Göran

sorphin said...

Well, I managed to crash FF 2.006 with your page, w/ no extensions running on a Mac running 10.4.10. Java Disabled. Javascript Enabled, no flash, nothing.

elwyn said...

I'm running ff 3.0.1 with winxp pro sp2. No crash on your site but plenty with ff.
Even with a new profile with nothing added by of plugins, addons it still did it.
any ideas?
leemcmindes@gmail.com