Closed
Bug 583209
Opened 14 years ago
Closed 14 years ago
Weave fails to load if system libnss3.so is in use (OpenSolaris, Linux dists)
Categories
(Firefox :: Sync, defect)
Firefox
Sync
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
blocking2.0 | --- | beta8+ |
People
(Reporter: ginnchen+exoracle, Assigned: glandium)
References
Details
(Whiteboard: [qa-])
Attachments
(2 files, 3 obsolete files)
(deleted),
application/x-xpinstall
|
Details | |
(deleted),
patch
|
glandium
:
review+
|
Details | Diff | Splinter Review |
In WeaveCrypto.js, it loads libnss3.so.
For OpenSolaris bundled Firefox, it is built with system nss libraries in /usr/lib/mps
So it failed to find libnss3.so in Firefox directory.
If I change the line to
append("/usr/lib/mps/libnss3.so");
it will work.
Ideally, we should honor LD_LIBRARY_PATH env variable and RUNPATH in firefox-bin or libxul.so ELF. (OpenSolaris bundled Firefox doesn't set LD_LIBRARY_PATH.)
I'm not sure jsctypes support it.
A workaround can be:
Try libnss3.so in GRE directory, if not found, try /usr/lib/mps/libnss3.so.
Updated•14 years ago
|
Component: General → Crypto
QA Contact: general → crypto
Comment 1•14 years ago
|
||
Debian's build of Firefox ("Iceweasel") apparently puts libnss3.so in /usr/lib or /usr/lib64 as well, causing Sync to disable itself on that platform.
Comment 2•14 years ago
|
||
Using ctypes.libraryName to get the library prefix/suffix might get the right filename, but we'll still have to check various directories for the right file?
Like on android, it checks for GRE/lib instead of just GRE. But is there a better way than check GRE then GRE/lib then LD_LIBRARY_PATH then more?
Flags: blocking-fx-sync1.5?
Comment 4•14 years ago
|
||
Speaking for Linux here:
dlopen() which is used from NSPR in the end lets the dynamic linker check where to find the lib if it's not given an absolute/relative path but just a filename.
Apparently that option is not provided through NSPR. At least I couldn't find it.
There is PR_GetLibraryPath() which seems to do something but it's not very up to date as it hardcodes /usr/lib:/lib but nowadays we are supporting /usr/lib64:/lib64 as well.
But probably this is a possible way and fixing remaining stuff in NSPR then?
So a proposal could be:
1. try to load with defined path
2. if not successful, find PR_GetLibraryPath() and iterate through the returned list
(3. fix PR_GetLibraryPath() do actually be a bit more up to date and complete)
?
Comment 5•14 years ago
|
||
(In reply to comment #4)
> 1. try to load with defined path
> 2. if not successful, find PR_GetLibraryPath() and iterate through the returned
> list
This would need to be done in the JS ctypes implementation probably.
Comment 6•14 years ago
|
||
If it's going to get us more standard semantics, I'd rather use dlopen() (and the corresponding Win32 API) rather than NSPR. Doing so would remove the jseng dependency on NSPR when ctypes is built, too.
Comment 7•14 years ago
|
||
(Note that to get RTLD_DEFAULT we need to use platform native APIs anyway -- NSPR doesn't provide that.)
Updated•14 years ago
|
Summary: Weave failed to load libnss3.so with OpenSolaris bundled Firefox → Weave fails to load if system libnss3.so is in use (OpenSolaris, Linux dists)
Assignee | ||
Comment 9•14 years ago
|
||
I tested this on the try server http://hg.mozilla.org/try/rev/67a06bf57496 and it apparently works.
Attachment #468627 -
Flags: review?
Assignee | ||
Comment 10•14 years ago
|
||
(In reply to comment #6)
> If it's going to get us more standard semantics, I'd rather use dlopen() (and
> the corresponding Win32 API) rather than NSPR. Doing so would remove the jseng
> dependency on NSPR when ctypes is built, too.
IIRC, ctypes is not the only thing that requires NSPR in js.
Comment 11•14 years ago
|
||
It is if you're not building JS_THREADSAFE.
Updated•14 years ago
|
Attachment #468627 -
Flags: review? → review?(dolske)
Comment 14•14 years ago
|
||
Comment on attachment 468627 [details] [diff] [review]
Use ctypes.libraryName and don't use a full path to load libnss3 from weavecrypto
> let os = Services.appinfo.OS;
I think you can get rid of this, too.
So by not using absolute path it magically works on Linux distros and Solaris where libnss is tucked away in /usr/lib?
Assignee | ||
Comment 15•14 years ago
|
||
(In reply to comment #14)
> So by not using absolute path it magically works on Linux distros and Solaris
> where libnss is tucked away in /usr/lib?
Most likely it will take whatever libnss was loaded by firefox.
Updated•14 years ago
|
OS: OpenSolaris → All
Hardware: x86 → All
Comment 16•14 years ago
|
||
Comment on attachment 468627 [details] [diff] [review]
Use ctypes.libraryName and don't use a full path to load libnss3 from weavecrypto
>+++ b/services/crypto/WeaveCrypto.js
...
>- let nssfile = Services.dirsvc.get("GreD", Ci.nsILocalFile);
> let os = Services.appinfo.OS;
>- switch (os) {
As noted above, the "let os = ..." can be removed now.
>- case "WebOS": // Palm Pre
>- nssfile.append("libnss3.so");
>- break;
>- case "Android":
>- // Android uses a $GREDIR/lib/ subdir.
>- nssfile.append("lib");
>- nssfile.append("libnss3.so");
>- break;
Should ping owners for these platforms, since they don't really have test coverage through try. At the least, so they're aware of this patch should Sync suddenly break.
Attachment #468627 -
Flags: review?(dolske) → review+
Comment 17•14 years ago
|
||
Mossop / mwu: CCing you to be on the lookout for any possible WebOS or Android breakage (see comment 16).
Assignee | ||
Comment 18•14 years ago
|
||
There was discussion on #developers a few days ago about this and bug 593484, and as to why the full path was needed in the first place. It would be better to double check the patch here works as expected when the system also has a system nss library installed, especially after bug 552864. I can definely check for Linux, but can't for other systems, though. I guess the main other system being affected would be Solaris ; I doubt windows and mac systems are likely to have a system nss.
Comment 19•14 years ago
|
||
(In reply to comment #18)
> I can definely check for Linux
Any news on this, Mike?
Assignee | ||
Comment 20•14 years ago
|
||
I can confirm that applying both attachment 468627 [details] [diff] [review] and bug 552864 doesn't break on linux when there is a system libnss3.so library.
Assignee | ||
Comment 21•14 years ago
|
||
Transferring Justin's r+ ; this is the same patch, only removing the now useless let os = ... part, and with commit message embedded.
Assignee: nobody → mh+mozilla
Attachment #468627 -
Attachment is obsolete: true
Attachment #480076 -
Flags: review+
Comment 22•14 years ago
|
||
(In reply to comment #17)
> Mossop / mwu: CCing you to be on the lookout for any possible WebOS or Android
> breakage (see comment 16).
We have some try server builds on http://ftp.mozilla.org/pub/mozilla.org/firefox/tryserver-builds/mh@glandium.org-6539ab9ab9d0/ now. I don't have an Android or Maemo phone handy, can somebody from the mobile team confirm that Sync still works with these builds?
Comment 23•14 years ago
|
||
Richard from Sync Ops just confirmed that the Android build worked.
Comment 24•14 years ago
|
||
So we're just waiting on fx-sync approval now, or do we need approval2.0 as well?
Comment 25•14 years ago
|
||
It can land on fx-sync now, and we'll pick it up with the next merge to m-c.
blocking2.0: --- → beta8+
Assignee | ||
Comment 26•14 years ago
|
||
Landed on fx-sync
http://hg.mozilla.org/services/fx-sync/rev/4ad5b1467331
Updated•14 years ago
|
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 27•14 years ago
|
||
Backed out again on fx-sync and m-c since it breaks OS X.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 28•14 years ago
|
||
I can confirm I reproduce the problem with the OSX nightly.
Comment 29•14 years ago
|
||
Can you install this restartless add-on? It'll open a new tab printing out the value of your nss filepath and ctypes path:
My results:
file: /Applications/Firefox x.x - Minefield.app/Contents/MacOS/libnss3.dylib
path: libnss3.dylib
bootstrap.js:
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function _() {
let gBrowser = Services.wm.getMostRecentWindow("navigator:browser").gBrowser;
gBrowser.selectedTab = gBrowser.addTab("data:text/html," + Array.join(arguments, "<br/><br/>"));
}
function startup(data, reason) {
// One-time scripts: auto-uninstall after running
AddonManager.getAddonByID(data.id, function(addon) {
addon.uninstall();
});
let file = Services.dirsvc.get("GreD", Ci.nsILocalFile);
file.append("libnss3.dylib");
let path = ctypes.libraryName("nss3");
_("file: " + file.path, "path: " + path);
}
Assignee | ||
Comment 30•14 years ago
|
||
(In reply to comment #29)
> file: /Applications/Firefox x.x - Minefield.app/Contents/MacOS/libnss3.dylib
> path: libnss3.dylib
Well, this is not unexpected, considering that was the whole point of the patch.
Assignee | ||
Comment 31•14 years ago
|
||
So, it appears that it works when running the firefox script directly from the command line, because it sets the proper DYLD_LIBRARY_PATH.
Assignee | ||
Comment 32•14 years ago
|
||
This one works for me. IMHO, the mac build should be arranged so that ctypes.open("somelib.dylib") without a full path, and for a library that is in the GRE directory, just works properly.
Attachment #480076 -
Attachment is obsolete: true
Attachment #481491 -
Flags: review?(dolske)
Comment 33•14 years ago
|
||
So one interesting thing I ran into when debugging this is that if you load the fullpath library, the short path loading will succeed.
Assignee | ||
Comment 34•14 years ago
|
||
(In reply to comment #33)
> So one interesting thing I ran into when debugging this is that if you load the
> fullpath library, the short path loading will succeed.
Which kind of makes sense, except that one would expect that to also happen after libnss is loaded as being depended upon by libxul. Looks like dlopen still needs some love on the system side on OSX.
Assignee | ||
Updated•14 years ago
|
Attachment #481491 -
Flags: review?(dolske) → review?(dwitte)
Comment 36•14 years ago
|
||
Comment on attachment 481491 [details] [diff] [review]
Use ctypes.libraryName and don't use a full path to load libnss3 from weavecrypto
r=dwitte
Attachment #481491 -
Flags: review?(dwitte) → review+
Comment 37•14 years ago
|
||
Comment on attachment 481491 [details] [diff] [review]
Use ctypes.libraryName and don't use a full path to load libnss3 from weavecrypto
Although...
>+ this.log("Using NSS library " + path);
This is kinda useless now. Move it inside the 'try', to say we're trying without path:
>+ try {
>+ nsslib = ctypes.open(path);
>+ } catch(e) {
>+ // In case opening the library without a full path fails,
>+ // try again with a full path.
and add a log line here to say that we're retrying with the full path.
>+ let file = Services.dirsvc.get("GreD", Ci.nsILocalFile);
>+ file.append(path);
>+ nsslib = ctypes.open(file.path);
Comment 38•14 years ago
|
||
Comment on attachment 481491 [details] [diff] [review]
Use ctypes.libraryName and don't use a full path to load libnss3 from weavecrypto
>+ var nsslib;
>+ try {
nits: Why not let here? Also both lines have trailing spaces.
Assignee | ||
Comment 39•14 years ago
|
||
(In reply to comment #38)
> >+ var nsslib;
> >+ try {
> nits: Why not let here? Also both lines have trailing spaces.
I thought let was used for let var = value type of definitions only.
(In reply to comment #37)
> Comment on attachment 481491 [details] [diff] [review]
> Use ctypes.libraryName and don't use a full path to load libnss3 from
> weavecrypto
>
> Although...
>
> >+ this.log("Using NSS library " + path);
>
> This is kinda useless now. Move it inside the 'try', to say we're trying
> without path:
>
> >+ try {
> >+ nsslib = ctypes.open(path);
> >+ } catch(e) {
> >+ // In case opening the library without a full path fails,
> >+ // try again with a full path.
>
> and add a log line here to say that we're retrying with the full path.
>
> >+ let file = Services.dirsvc.get("GreD", Ci.nsILocalFile);
> >+ file.append(path);
> >+ nsslib = ctypes.open(file.path);
Will do.
Assignee | ||
Comment 40•14 years ago
|
||
As landed on fx-sync (carrying over r+ ; addressed dwitte's comments)
http://hg.mozilla.org/services/fx-sync/rev/e947b5400606
Attachment #481491 -
Attachment is obsolete: true
Attachment #483423 -
Flags: review+
Comment 41•14 years ago
|
||
Resolved and tracked for the next merge (bug 604603)
Updated•14 years ago
|
Whiteboard: [qa-]
Updated•14 years ago
|
Flags: blocking-fx-sync1.5?
Updated•6 years ago
|
Component: Firefox Sync: Crypto → Sync
Product: Cloud Services → Firefox
You need to log in
before you can comment on or make changes to this bug.
Description
•