Skip to content

Commit

Permalink
Revert of Fix for VS2015 thread safe statics breaking in the sandbox …
Browse files Browse the repository at this point in the history
…(patchset Pissandshittium#2 id:20001 of https://codereview.chromium.org/1138463005/)

Reason for revert:
Suspect this is causing sbox_integration_tests to fail:

https://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%281%29/builds/37862

Original issue's description:
> Fix for VS2015 thread safe statics breaking in the sandbox
>
> The issue is that a function level static now takes a secret lock which is managed by the crt. Since the code in question executes before the crt has initialized, it uses an non-initialized lock.
>
> Current sandbox tests suffice.
>
> BUG=482784
>
> Committed: https://crrev.com/561ad2ebd6dd1b96ebbfe0d2656e44e21dba974c
> Cr-Commit-Position: refs/heads/master@{#331854}

TBR=scottmg@chromium.org,cpu@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=482784

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

Cr-Commit-Position: refs/heads/master@{#331900}
  • Loading branch information
samuong authored and Commit bot committed May 29, 2015
1 parent b40097f commit 5cde8dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
17 changes: 5 additions & 12 deletions sandbox/win/src/target_services.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ bool CloseOpenHandles() {
return true;
}

sandbox::TargetServicesBase* g_target_services = nullptr;

} // namespace

namespace sandbox {
Expand Down Expand Up @@ -102,10 +100,8 @@ ProcessState* TargetServicesBase::GetState() {
}

TargetServicesBase* TargetServicesBase::GetInstance() {
// Leak on purpose TargetServicesBase.
if (!g_target_services)
g_target_services = new (NT_ALLOC) TargetServicesBase;
return g_target_services;
static TargetServicesBase instance;
return &instance;
}

// The broker services a 'test' IPC service with the IPC_PING_TAG tag.
Expand Down Expand Up @@ -160,18 +156,15 @@ bool TargetServicesBase::TestIPCPing(int version) {
return true;
}

ProcessState::ProcessState() : process_state_(0) {
}

bool ProcessState::IsKernel32Loaded() const {
bool ProcessState::IsKernel32Loaded() {
return process_state_ != 0;
}

bool ProcessState::InitCalled() const {
bool ProcessState::InitCalled() {
return process_state_ > 1;
}

bool ProcessState::RevertedToSelf() const {
bool ProcessState::RevertedToSelf() {
return process_state_ > 2;
}

Expand Down
14 changes: 9 additions & 5 deletions sandbox/win/src/target_services.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ namespace sandbox {

class ProcessState {
public:
ProcessState();
ProcessState() : process_state_(0) {}

// Returns true if kernel32.dll has been loaded.
bool IsKernel32Loaded() const;
bool IsKernel32Loaded();

// Returns true if main has been called.
bool InitCalled() const;
bool InitCalled();

// Returns true if LowerToken has been called.
bool RevertedToSelf() const;
bool RevertedToSelf();

// Set the current state.
void SetKernel32Loaded();
void SetInitCalled();
void SetRevertedToSelf();

private:
public:
int process_state_;
DISALLOW_COPY_AND_ASSIGN(ProcessState);
};
Expand Down

0 comments on commit 5cde8dc

Please sign in to comment.