i-rinat / freshplayerplugin

ppapi2npapi compatibility layer
MIT License
727 stars 52 forks source link

race condition causes system to use 100% of CPU Resources #326

Open Zombie-Ryushu opened 8 years ago

Zombie-Ryushu commented 8 years ago

http://www.foreverymom.com/this-hilarious-mom-ranting-over-her-grocery-store-remodel-is-all-of-us/

This site triggers a Race condition that will make firefox and the plugin container use 100% of all possible CPU resources. Reverting to Netscape Flash resolves the issue. This is with Pepper Flash 23.0.0.213 and FreshPlayerPlugin 0.3.5

Zombie-Ryushu commented 8 years ago
[fresh] [error] [NP] caught Xlib error 2
[fresh] [error] [NP] caught Xlib error 2
[fresh] [error] [NP] caught Xlib error 4
[fresh] [error] [NP] caught Xlib error 4
[fresh] [error] [NP] caught Xlib error 9
[fresh] [error] [NP] caught Xlib error 9
[fresh] [error] [NP] caught Xlib error 171
[fresh] [error] [NP] caught Xlib error 171
[fresh] [error] ppb_graphics3d_create, glXMakeCurrent failed
[fresh] [error] ppb_graphics3d_create, glXMakeCurrent failed
[fresh] [error] [NP] caught Xlib error 2
[fresh] [error] [NP] caught Xlib error 2
[fresh] [error] [NP] caught Xlib error 4
[fresh] [error] [NP] caught Xlib error 4
[fresh] [error] [NP] caught Xlib error 9
[fresh] [error] [NP] caught Xlib error 9
[fresh] [error] [NP] caught Xlib error 171
[fresh] [error] [NP] caught Xlib error 171
[fresh] [error] ppb_graphics3d_create, glXMakeCurrent failed
[fresh] [error] ppb_graphics3d_create, glXMakeCurrent failed

Make sure you have Adblock disabled before trying this. Adblock will stop the Flash ad that creates the problem.

Zombie-Ryushu commented 8 years ago

This does not effect Chromium.

i-rinat commented 8 years ago

Today I realized that first time I tried to open that site, Firefox had a tracking protection activated, which blocked most parts of the page.

Now I can see the page content. It makes a noticable CPU load, but plugin-container process is barely visible in top output. In other words, I can't reproduce the bug.

i-rinat commented 8 years ago

[fresh] [error] ppb_graphics3d_create, glXMakeCurrent failed

High CPU load may be a consequence of failed 3d context creation. PepperFlash switches to PPB_Graphics2D, which implementation in freshplayerplugin is quite CPU-intensive. As for NPAPI Flash, it could be that VDPAU is used for scaling, lowering CPU usage.

Zombie-Ryushu commented 8 years ago

I think there is malicious flash coding in that site, and the malicious coding is creating the issue. I think that in some instances, malicious code may cause the high CPU usage. There need to be protections against that.

i-rinat commented 8 years ago

malicious code may cause the high CPU usage. There need to be protections against that.

There is a inherent property of NPAPI — synchronous Javascript queries in both directions, from browser to a plugin and from plugin to a browser. And that property makes it impossible to make any protection against eating CPU. Say, some Flash movie makes a long calculations in its main thread. If browser tries to make a query, it will wait until plugin's main thread will process it. Since that never happen, browser thread stalls. And as Firefox uses the same set of threads to draw all tabs and its interface, whole browser freezes.

To make such protection, browser part of interface needs to be changed in non-compatible way. Which was kind of made in PPAPI in Chromium. In PPAPI almost every call is asynchronous, so such freezes are extremely unlikely.

Firefox have some sort of protection — timeouts. By default, if plugin fails to respond in 60 seconds, plugin host process is terminated.