Closed Bug 1236865 Opened 5 years ago Closed 3 years ago

Unable to install Add-ons if NSS_DEFAULT_DB_TYPE=sql is set

Categories

(Toolkit :: Add-ons Manager, defect)

43 Branch
Unspecified
All
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: boris.bierwald, Unassigned)

References

Details

(Whiteboard: triaged)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0
Build ID: 20151216175450

Steps to reproduce:

Since Firefox 42 there is an issue with Add-ons if the NSS_DEFAULT_DB_TYPE environment variable is set to "sql" (to use the cert9+key4 NSS database file format).

If the user installs an Add-on from addons.mozilla.org (e.g. Web Developer, NoSquint or others) and restarts Firefox as 
requested, the Add-on will be deleted instantaneously. The browser console log states an error while reading the Add-on manifest because of "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" in XPCOMUtils.jsm (see full console log below).

If you copy the Add-on xpi file to your Firefox profile or to the global extension folder by yourself (instead of using addons.mozilla.org), the add-on will be successfully activated. But the moment the xpi's modification date is altered (no matter if zipped or extracted), the add-on will be deleted on the next firefox start because of an error in addons.xpi-updateMetadata (again: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)" in XPCOMUtils.jsm)

This issue affects restartless Add-ons, too. Simply close Firefox, alter the modification date of the XPI file (e.g. with "touch") and the Add-on will be deleted the next time Firefox starts.

Reproducible with:
* Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:42.0) Gecko/20100101 Firefox/42.0
* Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:43.0) Gecko/20100101 Firefox/43.0
* Firefox Developer Edition from mozilla.org (tested 17.12.2015): Mozilla/5.0 (X11; Linux i686; rv:44.0) Gecko/20100101 Firefox/44.0
* Firefox nightly from mozilla.org (tested 17.12.2015): Mozilla/5.0 (X11; Linux i686; rv:46.0) Gecko/20100101 Firefox/46.0
* Firefox 43.0.1 on Windows 7 SP1, 32Bit

Firefox versions prior to 42 (incl. 38.x ESR) are not affected by this issue. Because the environment variable affects NSS we replaced libnss3.so, libnssutil3.so and libssl3.so in Firefox 46 with the corresponding Firefox 41 versions but the issue persists.

Steps to Reproduce (using Linux, but same bug occurs using Windows):

a) By installation via Add-on Manager (addons.mozilla.org)

1) Open a terminal
2) Set the environment variable NSS_DEFAULT_DB_TYPE to "sql" ("export NSS_DEFAULT_DB_TYPE=sql")
3) Start Firefox from terminal (e.g. /usr/lib/firefox/firefox)
4) Open the Add-on Manager and install an Add-on from addon.mozilla.org that requires a restart (e.g. Web Developer or NoSquint) 
5) Restart Firefox on request
6) The Add-on will be deleted instantaneously due to an error
7) The browser console will state: 
	1450341722392	addons.xpi	ERROR	Unable to read add-on manifest from 
	/home/user/.mozilla/firefox/3mai452l.default/extensions/staged/nosquint@urandom.ca.xpi: 
	[Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) 
	[nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  
	location: "JS frame :: resource://gre/modules/XPCOMUtils.jsm :: XPCU_serviceLambda :: line 228"  
	data: no] 
	Stack trace: XPCU_serviceLambda()@resource://gre/modules/XPCOMUtils.jsm:228 
	< XPCU_defineLazyGetter/<.get()@resource://gre/modules/XPCOMUtils.jsm:196 
	< defineSyncGUID()@resource://gre/modules/addons/XPIProvider.jsm:1138 
	< loadManifestFromZipReader()@resource://gre/modules/addons/XPIProvider.jsm:1290 
	< next()@self-hosted:656 < TaskImpl_run()@resource://gre/modules/Task.jsm:314 
	< Handler.prototype.process()@resource://gre/modules/Promise.jsm 
	-> resource://gre/modules/Promise-backend.js:934 
	< this.PromiseWalker.walkerLoop()@resource://gre/modules/Promise.jsm 
	-> resource://gre/modules/Promise-backend.js:813 
	< this.PromiseWalker.scheduleWalkerLoop/
	<()@resource://gre/modules/Promise.jsm 
	-> resource://gre/modules/Promise-backend.js:747 
	< syncLoadManifestFromFile()@resource://gre/modules/addons/XPIProvider.jsm:1351 
	< XPI_processPendingFileChanges/<()@resource://gre/modules/addons/XPIProvider.jsm:2978 
	< forEach()@self-hosted:211 < XPI_processPendingFileChanges()@resource://gre/modules/addons/XPIProvider.jsm:2888 
	< XPI_checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3267 
	< XPI_startup()@resource://gre/modules/addons/XPIProvider.jsm:2518 
	< callProvider()@resource://gre/modules/AddonManager.jsm:221 
	< _startProvider()@resource://gre/modules/AddonManager.jsm:828 
	< AMI_startup()@resource://gre/modules/AddonManager.jsm:999 
	< AMP_startup()@resource://gre/modules/AddonManager.jsm:2673 
	< AMC_observe()@resource://gre/components/addonManager.js:58 
	< <file:unknown>

b) By manual install:

 1) Copy the xpi file to your Firefox profile extension folder
 2) Open a terminal
 3) Set the environment variable NSS_DEFAULT_DB_TYPE to "sql" ("export NSS_DEFAULT_DB_TYPE=sql")
 4) Start Firefox in terminal (/usr/lib/firefox/firefox)
 5) Activate Add-on
 6) Close Firefox
 7) Run Firefox => The Add-on should be active
 8) Close Firefox
 9) Change the modification date of one add-on (here: nosquint@urandom.ca.xpi) ("touch .mozilla/firefox/<USERPROFILE>/extensions/nosquint@urandom.ca.xpi")
10) Start Firefox again
11) The modified add-on will be deleted and the browser console will state an error message:
	1450275420754	addons.xpi-utils	WARN	addMetadata: Add-on nosquint@urandom.ca.xpi is invalid: 
	[Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) 
	[nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  
	location: "JS frame :: resource://gre/modules/XPCOMUtils.jsm :: XPCU_serviceLambda :: 
	line 230"  data: no] Stack trace: XPCU_serviceLambda()@resource://gre/modules/XPCOMUtils.jsm:230 
	< XPCU_defineLazyGetter/<.get()@resource://gre/modules/XPCOMUtils.jsm:198 
	< defineSyncGUID()@resource://gre/modules/addons/XPIProvider.jsm:1202 
	< loadManifestFromDir()@resource://gre/modules/addons/XPIProvider.jsm:1305 
	< TaskImpl_run()@resource://gre/modules/Task.jsm:314 
	< Handler.prototype.process()@resource://gre/modules/Promise.jsm 
	-> resource://gre/modules/Promise-backend.js:934 
	< this.PromiseWalker.walkerLoop()@resource://gre/modules/Promise.jsm 
	-> resource://gre/modules/Promise-backend.js:813



Actual results:

An installed Add-on will be deleted instantaneously or after the modification date was altered.


Expected results:

Installed Add-ons stay installed and active.
OS: Unspecified → All
Component: Untriaged → XPCOM
Product: Firefox → Core
Tim, can you use your new NSS expertise (:-) ) to clarify why this code:

https://dxr.mozilla.org/mozilla-central/rev/1ec3a3ff68f2d1a54e6ed33e926c28fee286bdf1/toolkit/mozapps/extensions/internal/XPIProvider.jsm#1250-1278

would fail in this case? It seems the Services.storage getter is throwing. I don't really understand why, although the comment there saying that that getter needs to run before NSS inits is a little worrying...
Component: XPCOM → Add-ons Manager
Flags: needinfo?(ttaubert)
Product: Core → Toolkit
(In reply to :Gijs Kruitbosch from comment #1)
> would fail in this case? It seems the Services.storage getter is throwing. I
> don't really understand why, although the comment there saying that that
> getter needs to run before NSS inits is a little worrying...

Wow, that's fun. It looks like Services.storage calls sqlite3_config upon initialization, and that fails if called after sqlite3_initialize. See bug 717904 comment 18, and bug 730495 comment 18.

Bug 730495 was filed to fix this properly but didn't get any attention for a while.
Flags: needinfo?(ttaubert)
Depends on: 730495, 783994
Whiteboard: triaged
Bug 1380706 implemented a workaround for the race between NSS init and the storage service.

It would be great to get a confirmation if bug 1380706 fixed the issue described here, too.
Flags: needinfo?(boris.bierwald)
Status: UNCONFIRMED → NEW
Ever confirmed: true
If this bug still relevant for WebExtensions?
(In reply to Andy McKay [:andym] from comment #4)
> If this bug still relevant for WebExtensions?

Potentially.  I actually think this might have been fixed by bug 1277295.
Regardless, if somebody has some cycles to try to reproduce in a recent build that would be great.
Krupa, any chance we could get some QA help to see if this was fixed by bug 1277295?  Its not pressing...
Flags: needinfo?(boris.bierwald) → needinfo?(krupa.mozbugs)
Attached image not deleted.gif
I was able to reproduce the bug in Firefox 47.0.2.

This bug is verified on Firefox 56.0 (20170926190823) under Windows 10 64bit. And not applicable for further version because webextensions don't require restart. If there are webextension that I should be testing or any further tests please let me know.

Please see the attached video.
Flags: needinfo?(krupa.mozbugs)
Thanks Marius!
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.