Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web page triggering EXC_BAD_ACCESS / KERN_INVALID_ADDRESS crash in Safari

I have a web app that's triggering what appears to be an iOS8 bug in Safari, and I'm looking for clues into what's setting it off and how to work around it.

The bug is characterized by "A problem occurred with this webpage so it was reloaded" appearing at the top of the page after the user has spent enough time navigating in Safari. It looks like something is crashing behind the scenes, and Safari is simply doing a really good job of gracefully recovering. Reading the crash log revealed this:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000000
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   JavaScriptCore                  0x2d4291d4 0x2d24a000 + 1962452
1   JavaScriptCore                  0x2d50e166 0x2d24a000 + 2900326
2   JavaScriptCore                  0x2d2bc88c 0x2d24a000 + 469132
...

Research hinted that instances of translate3d and keyframe in the CSS files might be to blame. While getting rid of them seemed to make the bug less likely to recur, the bug nevertheless still exists. Likewise, reducing the size of the (very, very large) CSS file associated with the pages most likely to trigger the bug seemed to help but not make it go away.

My company handles a bunch of mobile-optimized commerce-oriented web apps, and this is the only one that seems to be running afoul of this bug; I have no idea what's making this particular app such an angry little special snowflake, but I'd like to figure it out and correct it. Does anybody have any ideas about what might be triggering the bug and how we can work around it?

like image 938
BlairHippo Avatar asked Feb 10 '15 19:02

BlairHippo


People also ask

What is Exc_bad_access Kern_invalid_address?

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000. This indicates that your app crash because it tried to referenced NULL. Code Block. 0 CoreFoundation …

How to find EXC_ BAD_ access?

To debug an EXC_BAD_ACCESS, you can generally find out the where the dangling pointer is by enabling zombie objects. Choose edit scheme, then Diagnostics tab in the Run section, then click the 'Zombie Objects' option. Another cause for EXC_BAD_ACCESS can be infinite recursion, which can be found by adding some logging.

What does Kern_invalid_address mean?

EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS means that the virtual address you're refererencing is not in the page tables or you don't have access. It's a virtual address that you're not allowed to access.


2 Answers

I had the same problem as described. In my case crash occurred when part of application that controlled few DOM elements (i.e. element.style.width...) was completed. On completion those elements were intentionally removed from DOM. The crash occurred after that without any JS errors. With try and error I isolated which parts of code are responsible for this and in my case commenting all element.style.* lines solved the problem - application does not crash anymore. Only mobile safari (iOS 7 and 8) had this problem, other browsers worked fine.

Wild guess is that maybe something strange happens on garbage collection and is connected with DOM elements controlled by JS.

like image 192
frikovc Avatar answered Sep 23 '22 01:09

frikovc


I'm having the same exact problem with safari on iOS 8.1.3.

Actually the browser is acting a bit crazy. I have a load more button in my app which is wired to load next 20 records. Sometimes when you open the page and click on the link safari crashes with the "A problem occurred with this webpage so it was reloaded" message.

After it crashes and reloads it will crash every time. But when it works it's also stable.

Finally resolved the issue by limiting number of loaded records to 10 so it might have to do something with memory usage.

Also had this issue in a number of other places like image uploading or just loading some data via ajax.

What is more funny actually is that it never happens in chrome on iOS which actually uses webview component.

Not sure that it's of some help to you but it's not only your application so unless apple get it's act together and release a stable browser we can only try to work around some of it's limitations.

like image 3
korral Avatar answered Sep 21 '22 01:09

korral