This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Blink] Use RefPtr to ref the associated WebCLContext in WebCLObject.
Object derived from WebCLObject only keeps a weak reference to the associated WebCLContext object, so it may happen that the WebCLContext object is destructred after GC while the WebCLObject instance is still alive. Use-after-free will happen then, for example, in WebCLObject::~WebCLObject(). The following code shows a POC (xwalk needs to be started with --js-flags=--expose-gc to call garbage collection explicitly): var f = function () { var context = webcl.createContext(); return context.createCommandQueue(); }; var g = function() { var commandQueue = f(); gc(); // To ensure WebCLContext::~WebCLContext() is called. commandQueue.release(); }; g(); gc(); // To ensure WebCLCommandQueue::~WebCLCommandQueue is called. Use-after-free happens in WebCLObject::~WebCLObject(). This patch changes the raw pointer used in WebCLObject to RefPtr so that the WebCLContext object will not be destructed until all WebCLObject instances in this context are dead. No circular reference should be introduced here since WebCLObject instances are tracked with weak pointers in WebCLContext. BUG=XWALK-3979
- Loading branch information
Showing
19 changed files
with
70 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.