Closed
Bug 529216
Opened 15 years ago
Closed 15 years ago
Fix for #521750 breaks embedding on Windows due to usage of TLS
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 526586
People
(Reporter: matthall, Unassigned)
References
Details
Attachments
(1 file)
3.74 KB,
application/octet-stream
|
Details |
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
The fix for bug #512750 added a variable to track the "main" thread that is declared using "__declspec(thread)". This works fine for Firefox, but there are issues using "__declspec(thread)" for code that is loaded via LoadLibrary, which is how embedders (indirectly) load XPCOM via XRE_InitEmbedding. As a result, embedding is broken in Windows XP. See the following two links for more information:
http://support.microsoft.com/kb/118816
"DLLs that use __declspec(thread) should not be loaded with LoadLibrary."
http://msdn.microsoft.com/en-us/library/2s9wt68x(VS.80).aspx
"If a DLL declares any nonlocal data or object as __declspec( thread ), it can cause a protection fault if dynamically loaded. After the DLL is loaded with LoadLibrary, it causes system failure whenever the code references the nonlocal __declspec( thread ) data."
The symptom is exactly as described: we crash upon trying to set that TLS variable. The stack is as follows:
xul.dll!nsThreadManager::Init() Line 110 + 0xc bytes C++
xul.dll!NS_InitXPCOM3_P(nsIServiceManager * * result=, nsIFile * binDirectory=, nsIDirectoryServiceProvider * appFileLocationProvider=, const nsStaticModuleInfo * staticComponents=, unsigned int componentCount=) Line 555 C++
mozcrt19.dll!arena_malloc_small(arena_s * arena=0x00000000, unsigned int size=0, int zero=79818912) Line 4075 C
xul.dll!XRE_InitEmbedding(nsILocalFile * aLibXULDirectory=0x04c171c0, nsILocalFile * aAppDirectory=0x04c330b0, nsIDirectoryServiceProvider * aAppDirProvider=0x00000031, const nsStaticModuleInfo * aStaticComponents=0x04c33238, unsigned int aStaticComponentCount=0) Line 124 + 0x18 bytes C++
The following line of code is causing the crash:
#ifdef NS_TLS
gTLSIsMainThread = true;
#endif
Reproducible: Sometimes
Steps to Reproduce:
1. Write a small app that links against XulRunner and loads XPCOM via XRE_InitEmbedding on XP.
Actual Results:
Crash
Expected Results:
XPCOM initializes fine.
I took winEmbed.cpp and trimmed it down to the smallest possible repro for this bug. If you run this on Windows XP against Firefox 3.5.5, it will crash. To compile you'll have to change a few things:
1. Fix up the include directories to point to wherever you have the XulRunner SDK
2. Do the same for the lib directories
3. Change the hard-coded XPCOM path variable (line #78) to point to you Firefox 3.5.5 install location.
This seems like a duplicate of bug 526586.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•