New issue
Advanced search Search tips

Issue 697994 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

mayNotBeMainThread is sensitive to which thread it is first called on

Project Member Reported by jbroman@chromium.org, Mar 2 2017

Issue description

This makes it dangerous to add call sites to this useful trick. Instead, it should initialize once (along with the rest of WTF main thread initialization). As a bonus, this makes the inline function substantially shorter (especially now that we have threadsafe static locals in Chromium).
 
Good point... Nice detective work!

Project Member

Comment 2 by bugdroid1@chromium.org, Mar 7 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140

commit 11dcf4d494498d0a49f8a1674ad2a9f1e1f59140
Author: jbroman <jbroman@chromium.org>
Date: Tue Mar 07 18:38:07 2017

WTF: Initialize main-thread stack estimates when WTF starts up.

Initializing this statically makes it sensitive to which thread it runs on for
the first time. Instead of using a static local, an ordinary global variable
is initialized once, when WTF knows it is on the main thread.

As a side effect, the check for static initialization in the function itself
is no longer required (and happens to even be safe if it is called before
initialization), which means the function need not be exported (only the
variables must be), and should compile to less code.

Finally, the method (which is useful to callers outside of WTF) is moved into
the general WTF namespace, and only the implementation details are kept in
WTF::internal.

BUG= 697994 

Review-Url: https://codereview.chromium.org/2728453006
Cr-Commit-Position: refs/heads/master@{#455150}

[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/StackUtil.cpp
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/StackUtil.h
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/ThreadSpecific.h
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/Threading.h
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/ThreadingPthreads.cpp
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/ThreadingWin.cpp
[modify] https://crrev.com/11dcf4d494498d0a49f8a1674ad2a9f1e1f59140/third_party/WebKit/Source/wtf/WTF.cpp

Status: Fixed (was: Started)

Sign in to add a comment