Closed Bug 615328 Opened 14 years ago Closed 7 years ago

move assertion that PSM initialization can only happen on the main thread to an obvious place (like nsNSSComponent::Init)

Categories

(Core :: Security: PSM, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1273475

People

(Reporter: sdwilsh, Unassigned)

References

Details

(Whiteboard: [psm-cleanup])

Specifically, if you try to initialize PSM off of the main thread, you'll end up asserting because nsNSSComponent::Init will end up creating a new nsIURI via NS_NewURI, which can only be done on the main thread.  The stack for this situation looks something like this:

 	mozalloc.dll!mozalloc_abort(const char * const msg=0x0487eb04)  Line 77	C++
 	xul.dll!Abort(const char * aMsg=0x0487eb04)  Line 379 + 0xa bytes	C++
 	xul.dll!NS_DebugBreak_P(unsigned int aSeverity=0x00000001, const char * aStr=0x6a8fe17c, const char * aExpr=0x6a8fe168, const char * aFile=0x6a8fe110, int aLine=0x00000203)  Line 366 + 0xc bytes	C++
 	xul.dll!nsIOService::NewURI(const nsACString_internal & aSpec={...}, const char * aCharset=0x00000000, nsIURI * aBaseURI=0x00000000, nsIURI * * result=0x0487f040)  Line 515 + 0x27 bytes	C++
 	xul.dll!NS_NewURI(nsIURI * * result=0x0487f040, const nsACString_internal & spec={...}, const char * charset=0x00000000, nsIURI * baseURI=0x00000000, nsIIOService * ioService=0x0057ff28)  Line 178 + 0x1e bytes	C++
>	xul.dll!nsStringBundle::LoadProperties()  Line 121 + 0x2a bytes	C++
 	xul.dll!nsStringBundle::GetStringFromName(const wchar_t * aName=0x6a6838b8, wchar_t * * aResult=0x0487f190)  Line 274 + 0x8 bytes	C++
 	xul.dll!nsNSSComponent::Init()  Line 1888 + 0x3d bytes	C++
 	xul.dll!nsNSSComponentConstructor(nsISupports * aOuter=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f2a4)  Line 217 + 0xb8 bytes	C++
 	xul.dll!mozilla::GenericFactory::CreateInstance(nsISupports * aOuter=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f2a4)  Line 48 + 0x14 bytes	C++
 	xul.dll!nsComponentManagerImpl::CreateInstanceByContractID(const char * aContractID=0x6a6826b4, nsISupports * aDelegate=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f2a4)  Line 1303 + 0x25 bytes	C++
 	xul.dll!nsComponentManagerImpl::GetServiceByContractID(const char * aContractID=0x6a6826b4, const nsID & aIID={...}, void * * result=0x0487f30c)  Line 1664 + 0x34 bytes	C++
 	xul.dll!CallGetService(const char * aContractID=0x6a6826b4, const nsID & aIID={...}, void * * aResult=0x0487f30c)  Line 95	C++
 	xul.dll!nsGetServiceByContractID::operator()(const nsID & aIID={...}, void * * aInstancePtr=0x0487f30c)  Line 278 + 0x13 bytes	C++
 	xul.dll!nsCOMPtr<nsINSSComponent>::assign_from_gs_contractid(const nsGetServiceByContractID gs={...}, const nsID & aIID={...})  Line 1252 + 0xf bytes	C++
 	xul.dll!nsCOMPtr<nsINSSComponent>::nsCOMPtr<nsINSSComponent>(const nsGetServiceByContractID gs={...})  Line 628	C++
 	xul.dll!EnsureNSSInitialized(EnsureNSSOperator op=nssEnsure)  Line 356	C++
 	xul.dll!nsRandomGeneratorConstructor(nsISupports * aOuter=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f434)  Line 260 + 0x2b bytes	C++
 	xul.dll!mozilla::GenericFactory::CreateInstance(nsISupports * aOuter=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f434)  Line 48 + 0x14 bytes	C++
 	xul.dll!nsComponentManagerImpl::CreateInstanceByContractID(const char * aContractID=0x6a77c0b0, nsISupports * aDelegate=0x00000000, const nsID & aIID={...}, void * * aResult=0x0487f434)  Line 1303 + 0x25 bytes	C++
 	xul.dll!nsComponentManagerImpl::GetServiceByContractID(const char * aContractID=0x6a77c0b0, const nsID & aIID={...}, void * * result=0x0487f49c)  Line 1664 + 0x34 bytes	C++
 	xul.dll!CallGetService(const char * aContractID=0x6a77c0b0, const nsID & aIID={...}, void * * aResult=0x0487f49c)  Line 95	C++
 	xul.dll!nsGetServiceByContractID::operator()(const nsID & aIID={...}, void * * aInstancePtr=0x0487f49c)  Line 278 + 0x13 bytes	C++
 	xul.dll!nsCOMPtr<nsIRandomGenerator>::assign_from_gs_contractid(const nsGetServiceByContractID gs={...}, const nsID & aIID={...})  Line 1252 + 0xf bytes	C++
 	xul.dll!nsCOMPtr<nsIRandomGenerator>::nsCOMPtr<nsIRandomGenerator>(const nsGetServiceByContractID gs={...})  Line 628	C++
This blocks a blocker, so blocking betaN
blocking2.0: --- → betaN+
After talking about this on irc, I will work around this issue, and we'll add an assertion (what this bug is about now) to nsNSSComponent::Init stating that it is main thread only.
No longer blocks: 607112
blocking2.0: betaN+ → ---
Summary: PSM can create main-thread-only objects off of the main thread → PSM can create main-thread-only objects off of the main thread, so assert that it cannot be used off of the main thread
There already is an assertion, but it's not in the obvious place (InitializeCipherSuite). We can clean this up a bit.
Blocks: 1215267
Summary: PSM can create main-thread-only objects off of the main thread, so assert that it cannot be used off of the main thread → move assertion that PSM initialization can only happen on the main thread to an obvious place (like nsNSSComponent::Init)
Whiteboard: [psm-cleanup]
I believe this was addressed as part of the fix for Bug 1273475:
https://hg.mozilla.org/mozilla-central/rev/990954b29382#l1.83
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.