Skip to content

Commit

Permalink
Delete the PNaCl translate thread before deleting object files on sur…
Browse files Browse the repository at this point in the history
…faway.

Can't currently use base's ScopedVector for obj_files
(instead of manual deletion), because base's [D]CHECK
macros conflict with the NaCl ones that currently
get pulled in.

BUG=348742
TEST= currently manual:
Put a sleep(n) at the right place in the translate
thread and surf away -- observe before and after the patch.

R=teravest@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254872 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jvoung@google.com committed Mar 4, 2014
1 parent 15e4c67 commit e4be782
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ PnaclCoordinator::~PnaclCoordinator() {
plugin_->pp_instance(),
PP_FALSE);
}
// Force deleting the translate_thread now. It must be deleted
// before any scoped_* fields hanging off of PnaclCoordinator
// since the thread may be accessing those fields.
// It will also be accessing obj_files_.
translate_thread_.reset(NULL);
// TODO(jvoung): use base/memory/scoped_vector.h to hold obj_files_.
for (int i = 0; i < num_object_files_opened_; i++) {
delete obj_files_[i];
}
Expand Down
4 changes: 2 additions & 2 deletions ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> {
int64_t expected_pexe_size_; // Expected download total (-1 if unknown).

// The helper thread used to do translations via SRPC.
// Keep this last in declaration order to ensure the other variables
// haven't been destroyed yet when its destructor runs.
// It accesses fields of PnaclCoordinator so it must have a
// shorter lifetime.
nacl::scoped_ptr<PnaclTranslateThread> translate_thread_;
};

Expand Down

0 comments on commit e4be782

Please sign in to comment.