WorkerThread's pointer should be protected until all the shutdown tasks are complete
WorkerThread's pointer should be protected until all the shutdown tasks are complete

During destruction of WorkerThread, m_pendingGCRunner is destroyed prior to m_thread,
because it is following it in the members ordering in the class.
So when m_thread is being destroyed, it is waiting for all the tasks on the message loop
to complete, some of which need the PendingGCRunner. This will cause use-after-free.

To prevent the situation, this CL adds code to keep the WorkerThread pointer alive
until we complete all the shutdown tasks.

BUG=400511
TEST=none (I cannot reproduce the crash)
R=ager@chromium.org, jochen@chromium.org, nasko@chromium.org, zerny@chromium.org

Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=179604

Review URL: https://codereview.chromium.org/445863002

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@179668 bbb929c8-8fbe-4397-9dbb-9b2b20218538

smishenk/blink-crosswalk,ondra-novak/blink,hgl888/blink-crosswalk-efl,kurli/blink-crosswalk,modulexcite/blink,Bysmyyr/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,nwjs/blink,modulexcite/blink,hgl888/blink-crosswalk-efl,crosswalk-project/blink-crosswalk-efl,modulexcite/blink,hgl888/blink-crosswalk-efl,jtg-gg/blink,nwjs/blink,XiaosongWei/blink-crosswalk,jtg-gg/blink,modulexcite/blink,jtg-gg/blink,modulexcite/blink,Bysmyyr/blink-crosswalk,smishenk/blink-crosswalk,modulexcite/blink,ondra-novak/blink,smishenk/blink-crosswalk,kurli/blink-crosswalk,Pluto-tv/blink-crosswalk,nwjs/blink,XiaosongWei/blink-crosswalk,kurli/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,XiaosongWei/blink-crosswalk,kurli/blink-crosswalk,ondra-novak/blink,Pluto-tv/blink-crosswalk,ondra-novak/blink,PeterWangIntel/blink-crosswalk,modulexcite/blink,Pluto-tv/blink-crosswalk,hgl888/blink-crosswalk-efl,smishenk/blink-crosswalk,hgl888/blink-crosswalk-efl,PeterWangIntel/blink-crosswalk,kurli/blink-crosswalk,kurli/blink-crosswalk,Pluto-tv/blink-crosswalk,PeterWangIntel/blink-crosswalk,Pluto-tv/blink-crosswalk,smishenk/blink-crosswalk,XiaosongWei/blink-crosswalk,PeterWangIntel/blink-crosswalk,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,PeterWangIntel/blink-crosswalk,hgl888/blink-crosswalk-efl,modulexcite/blink,nwjs/blink,smishenk/blink-crosswalk,hgl888/blink-crosswalk-efl,ondra-novak/blink,Bysmyyr/blink-crosswalk,XiaosongWei/blink-crosswalk,Bysmyyr/blink-crosswalk,smishenk/blink-crosswalk,jtg-gg/blink,XiaosongWei/blink-crosswalk,XiaosongWei/blink-crosswalk,Bysmyyr/blink-crosswalk,Bysmyyr/blink-crosswalk,jtg-gg/blink,nwjs/blink,jtg-gg/blink,nwjs/blink,crosswalk-project/blink-crosswalk-efl,XiaosongWei/blink-crosswalk,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,ondra-novak/blink,XiaosongWei/blink-crosswalk,PeterWangIntel/blink-crosswalk,nwjs/blink,PeterWangIntel/blink-crosswalk,nwjs/blink,XiaosongWei/blink-crosswalk,modulexcite/blink,Pluto-tv/blink-crosswalk,nwjs/blink,jtg-gg/blink,kurli/blink-crosswalk,smishenk/blink-crosswalk,smishenk/blink-crosswalk,kurli/blink-crosswalk,Pluto-tv/blink-crosswalk,ondra-novak/blink,modulexcite/blink,Bysmyyr/blink-crosswalk,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,ondra-novak/blink,ondra-novak/blink,crosswalk-project/blink-crosswalk-efl,jtg-gg/blink,hgl888/blink-crosswalk-efl,crosswalk-project/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,PeterWangIntel/blink-crosswalk,jtg-gg/blink,jtg-gg/blink,crosswalk-project/blink-crosswalk-efl,smishenk/blink-crosswalk,kurli/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,nwjs/blink,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk,PeterWangIntel/blink-crosswalk