Replace the workaround for bug 40663 by the real fix.
R=agl
BUG=40663
TEST=Run chrome.exe on Windows. Use SSL. Shut down Chrome.
All chrome.exe processes should terminate.
Review URL: http://codereview.chromium.org/3113004
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/nss@55588 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/README.chromium b/README.chromium
index df581d9..545ac38 100644
--- a/README.chromium
+++ b/README.chromium
@@ -28,12 +28,6 @@
- patches/nspr-static.patch: to build NSPR as static libraries. See NSPR
bug 533014 (https://bugzilla.mozilla.org/show_bug.cgi?id=533014).
- patches/prcpucfg.h: added to the mozilla/nsprpub/pr/include directory.
-- patches/nspr-attach-as-system-thread.patch: attach a "foreign" thread
- (a thread not created by NSPR) to NSPR as a "system" thread rather than
- a "user" thread, which needs to terminate before PR_Cleanup can return.
- (The "system" vs. "user" thread distinction comes from Java, and
- ultimately from Solaris threads.) This is a workaround for
- http://crbug.com/40663.
We made the following local changes to NSS.
- patches/nss-static.patch: to build NSS as static libraries and omit
diff --git a/mozilla/nsprpub/pr/src/md/windows/w95thred.c b/mozilla/nsprpub/pr/src/md/windows/w95thred.c
index 9fb13e4..0c45306 100644
--- a/mozilla/nsprpub/pr/src/md/windows/w95thred.c
+++ b/mozilla/nsprpub/pr/src/md/windows/w95thred.c
@@ -309,7 +309,7 @@
if (NULL == thread) {
thread = _PRI_AttachThread(
- PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
+ PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
}
PR_ASSERT(thread != NULL);
return thread;
@@ -353,17 +353,19 @@
// This magic is from http://www.codeproject.com/threads/tls.asp
// and it works for VC++ 7.0 and later.
+// Force a reference to _tls_used to make the linker create the TLS directory
+// if it's not already there. (e.g. if __declspec(thread) is not used).
+// Force a reference to p_thread_callback_nspr to prevent whole program
+// optimization from discarding the variable.
#ifdef _WIN64
-// This makes the linker create the TLS directory if it's not already
-// there. (e.g. if __declspec(thread) is not used).
#pragma comment(linker, "/INCLUDE:_tls_used")
+#pragma comment(linker, "/INCLUDE:p_thread_callback_nspr")
#else // _WIN64
-// This makes the linker create the TLS directory if it's not already
-// there. (e.g. if __declspec(thread) is not used).
#pragma comment(linker, "/INCLUDE:__tls_used")
+#pragma comment(linker, "/INCLUDE:_p_thread_callback_nspr")
#endif // _WIN64
@@ -399,15 +401,19 @@
// implicitly loaded.
//
// See VC\crt\src\tlssup.c for reference.
+
+// The linker must not discard p_thread_callback_nspr. (We force a reference
+// to this variable with a linker /INCLUDE:symbol pragma to ensure that.) If
+// this variable is discarded, the PR_OnThreadExit function will never be
+// called.
#ifdef _WIN64
// .CRT section is merged with .rdata on x64 so it must be constant data.
#pragma const_seg(".CRT$XLB")
// When defining a const variable, it must have external linkage to be sure the
-// linker doesn't discard it. If this value is discarded, the PR_OnThreadExit
-// function will never be called.
-extern const PIMAGE_TLS_CALLBACK p_thread_callback;
-const PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit;
+// linker doesn't discard it.
+extern const PIMAGE_TLS_CALLBACK p_thread_callback_nspr;
+const PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
// Reset the default section.
#pragma const_seg()
@@ -415,7 +421,7 @@
#else // _WIN64
#pragma data_seg(".CRT$XLB")
-PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit;
+PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
// Reset the default section.
#pragma data_seg()
diff --git a/patches/nspr-attach-as-system-thread.patch b/patches/nspr-attach-as-system-thread.patch
deleted file mode 100644
index 706dbd9..0000000
--- a/patches/nspr-attach-as-system-thread.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-Index: mozilla/nsprpub/pr/src/md/windows/w95thred.c
-===================================================================
-RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95thred.c,v
-retrieving revision 3.18
-diff -u -p -u -8 -r3.18 w95thred.c
---- mozilla/nsprpub/pr/src/md/windows/w95thred.c 4 Feb 2009 23:44:01 -0000 3.18
-+++ mozilla/nsprpub/pr/src/md/windows/w95thred.c 20 Apr 2010 18:06:13 -0000
-@@ -304,13 +304,13 @@ PRThread*
- _MD_CURRENT_THREAD(void)
- {
- PRThread *thread;
-
- thread = _MD_GET_ATTACHED_THREAD();
-
- if (NULL == thread) {
- thread = _PRI_AttachThread(
-- PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
-+ PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
- }
- PR_ASSERT(thread != NULL);
- return thread;
- }
diff --git a/patches/nspr-static.patch b/patches/nspr-static.patch
index 06dc86c..d966db2 100644
--- a/patches/nspr-static.patch
+++ b/patches/nspr-static.patch
@@ -1,10 +1,10 @@
Index: mozilla/nsprpub/pr/include/prtypes.h
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/include/prtypes.h,v
-retrieving revision 3.41
-diff -p -u -8 -r3.41 prtypes.h
---- mozilla/nsprpub/pr/include/prtypes.h 6 May 2009 05:40:35 -0000 3.41
-+++ mozilla/nsprpub/pr/include/prtypes.h 15 Jan 2010 01:23:40 -0000
+retrieving revision 3.43
+diff -p -u -8 -r3.43 prtypes.h
+--- mozilla/nsprpub/pr/include/prtypes.h 11 Jun 2010 01:34:54 -0000 3.43
++++ mozilla/nsprpub/pr/include/prtypes.h 10 Aug 2010 01:06:02 -0000
@@ -75,17 +75,33 @@
** Example:
** in dowhim.h
@@ -46,7 +46,7 @@
retrieving revision 3.8
diff -p -u -8 -r3.8 w95dllmain.c
--- mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 25 Apr 2004 15:01:00 -0000 3.8
-+++ mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 15 Jan 2010 01:23:40 -0000
++++ mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 10 Aug 2010 01:06:02 -0000
@@ -30,16 +30,18 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
@@ -80,11 +80,11 @@
Index: mozilla/nsprpub/pr/src/md/windows/w95thred.c
===================================================================
RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95thred.c,v
-retrieving revision 3.18
-diff -p -u -8 -r3.18 w95thred.c
---- mozilla/nsprpub/pr/src/md/windows/w95thred.c 4 Feb 2009 23:44:01 -0000 3.18
-+++ mozilla/nsprpub/pr/src/md/windows/w95thred.c 15 Jan 2010 01:23:40 -0000
-@@ -309,8 +309,115 @@ PRThread *thread;
+retrieving revision 3.19
+diff -p -u -8 -r3.19 w95thred.c
+--- mozilla/nsprpub/pr/src/md/windows/w95thred.c 11 Jun 2010 01:34:54 -0000 3.19
++++ mozilla/nsprpub/pr/src/md/windows/w95thred.c 10 Aug 2010 01:06:02 -0000
+@@ -309,8 +309,121 @@ PRThread *thread;
if (NULL == thread) {
thread = _PRI_AttachThread(
@@ -132,17 +132,19 @@
+// This magic is from http://www.codeproject.com/threads/tls.asp
+// and it works for VC++ 7.0 and later.
+
++// Force a reference to _tls_used to make the linker create the TLS directory
++// if it's not already there. (e.g. if __declspec(thread) is not used).
++// Force a reference to p_thread_callback_nspr to prevent whole program
++// optimization from discarding the variable.
+#ifdef _WIN64
+
-+// This makes the linker create the TLS directory if it's not already
-+// there. (e.g. if __declspec(thread) is not used).
+#pragma comment(linker, "/INCLUDE:_tls_used")
++#pragma comment(linker, "/INCLUDE:p_thread_callback_nspr")
+
+#else // _WIN64
+
-+// This makes the linker create the TLS directory if it's not already
-+// there. (e.g. if __declspec(thread) is not used).
+#pragma comment(linker, "/INCLUDE:__tls_used")
++#pragma comment(linker, "/INCLUDE:_p_thread_callback_nspr")
+
+#endif // _WIN64
+
@@ -178,15 +180,19 @@
+// implicitly loaded.
+//
+// See VC\crt\src\tlssup.c for reference.
++
++// The linker must not discard p_thread_callback_nspr. (We force a reference
++// to this variable with a linker /INCLUDE:symbol pragma to ensure that.) If
++// this variable is discarded, the PR_OnThreadExit function will never be
++// called.
+#ifdef _WIN64
+
+// .CRT section is merged with .rdata on x64 so it must be constant data.
+#pragma const_seg(".CRT$XLB")
+// When defining a const variable, it must have external linkage to be sure the
-+// linker doesn't discard it. If this value is discarded, the PR_OnThreadExit
-+// function will never be called.
-+extern const PIMAGE_TLS_CALLBACK p_thread_callback;
-+const PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit;
++// linker doesn't discard it.
++extern const PIMAGE_TLS_CALLBACK p_thread_callback_nspr;
++const PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
+
+// Reset the default section.
+#pragma const_seg()
@@ -194,7 +200,7 @@
+#else // _WIN64
+
+#pragma data_seg(".CRT$XLB")
-+PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit;
++PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
+
+// Reset the default section.
+#pragma data_seg()