Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[linux-distros-dev] SWT: NS_InitEmbedding vs. NS_InitXPCOM

Hi,

I've been working on this bug for the past few days but I seem to be getting
nowhere:

  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=201778

The bug is caused because upstream SWT makes use of symbols that are in the
statically-linked firefox builds but not in our (Fedora) dynamically-linked
builds.  Below I outline the situation and detail attempts I have made to fix
it.

I have read a lot of documentation on XPCOM and embedding, but all of it
seems to say you must use NS_InitEmbedding.  Chris Aillon suggested I use
NS_InitXPCOM3 (or 2) instead.  That seemed to solve the issue of building and
basic usage but then we ran into the problem of sites that request the
passwordmanager not working ([1] below).  Also, https sites do not work ([2]
below).  Note that SWT is written in Java so there is some JNI involved.

I would greatly appreciate any pointers to docs or even better some guidance
as to what we can do to fix this.  Ideally, SWT would be able to work with
both older Mozilla releases (1.4, 1.7), Firefox downloads, *and* xulrunner.

Thanks very much,

Andrew

Here are the details:

previously with NS_InitEmbedding()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  xpcom.cpp:
  =========
  NS_InitEmbedding:
    rc = (jint)NS_InitEmbedding((nsILocalFile *)arg0,
                                (nsIDirectoryServiceProvider *)arg1);
  ProfileDirServiceProvider_Register:
    rc = (jint)((nsProfileDirServiceProvider *)arg0)->Register();
  ProfileDirServiceProvider_SetProfileDir:
    rc = (jint)((nsProfileDirServiceProvider *)arg0)->SetProfileDir(
           (nsIFile *)arg1);

  Browser.java:
  ============
  rc = XPCOM.NS_InitEmbedding(localFile.getAddress(), 0); 
  ...
  rc = XPCOM_PROFILE.NS_NewProfileDirServiceProvider(true, result);
  final int /*long*/ dirServiceProvider = result[0];
  result[0] = 0;
  rc = XPCOM_PROFILE.ProfileDirServiceProvider_Register(dirServiceProvider);
  rc = XPCOM_PROFILE.ProfileDirServiceProvider_SetProfileDir(
         dirServiceProvider, profileDir.getAddress());

now with NS_InitXPCOM3():
~~~~~~~~~~~~~~~~~~~~~~~~

  xpcom.cpp:
  =========
  rc = (jint)NS_InitXPCOM3((nsIServiceManager **)arg0,
                           (nsIFile *)arg1,
                           (nsIDirectoryServiceProvider *)arg2,
                           (nsStaticModuleInfo *)arg3,
                           (PRUint32) arg4);

  Browser.java:
  ============
  rc = XPCOM.NS_InitXPCOM3(0, localFile.getAddress(), 0, 0, 0);
  ...
  ?

issues:
~~~~~~
1. Crashes on sites that look for passwordmanager (ex. Slashdot):

0x04844aa0 in nsPasswordManager::Init (this=0x950ec08)
    at nsPasswordManager.cpp:290
290       mSignonFile->AppendNative(signonFile);
Current language:  auto; currently c++
(gdb) bt
#0  0x04844aa0 in nsPasswordManager::Init (this=0x950ec08)
    at nsPasswordManager.cpp:290
#1  0x04844c18 in nsPasswordManager::GetInstance ()
    at nsPasswordManager.cpp:233

(see entire trace at bottom [1])

  - attempted to resolve with:

    byte[] buffer = Converter.wcsToMbcs(null, "@mozilla.org/passwordmanager;1", true);
    byte[] aContractID = new byte [buffer.length + 1];
    System.arraycopy (buffer, 0, aContractID, 0, buffer.length);
    rc = serviceManager.GetServiceByContractID (
      aContractID,
      new nsID("173562f0-2173-11d5-a54C-0010a401eb10"),
      result);

  - dies in GetServiceByContractID call
  - do I need to pass a PasswordManager in the list of staticComponents?

2. Crashes on https

NSSRWLock_LockRead (rwlock=0x0) at nssrwlk.c:212
212         PZ_Lock(rwlock->rw_lock);
(gdb) bt
#0  NSSRWLock_LockRead (rwlock=0x0) at nssrwlk.c:212

(see entire trace at bottom [2])

  - attempted to resolve with:

    buffer = Converter.wcsToMbcs(null, XPCOM.NS_PROFILE_CONTRACTID, true);
    rc = serviceManager.GetServiceByContractID(buffer, nsIProfile.NS_IPROFILE_IID, result);
  System.out.println(" ERROR: " + Integer.toHexString(rc));
    if (rc != XPCOM.NS_OK) error(rc);
    if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);
    nsIProfile profile = new nsIProfile(result[0]);
    result[0] = 0;
    rc = profile.GetCurrentProfile(result);

    => ERROR: 80040154
      which corresponds to:  NS_ERROR_FACTORY_NOT_REGISTERED

    I think this is because the build is done with MOZ_SINGLE_PROFILE

  - also attempted to resolve with:

    buffer = XPCOM.NS_DIRECTORYSERVICEPROVIDER_CONTRACTID.getBytes();
    aContractID = new byte[buffer.length + 1];
    System.arraycopy(buffer, 0, aContractID, 0, buffer.length);
    rc = serviceManager.GetServiceByContractID(aContractID, nsIDirectoryServiceProvider.NS_IDIRECTORYSERVICEPROVIDER_IID, result);
    if (rc != XPCOM.NS_OK) error(rc);
    if (result[0] == 0) error(XPCOM.NS_NOINTERFACE);

    // And then could I do something like this?
    nsProfileDirServiceProvider profileDirServiceProvider = new nsProfileDirServiceProvider(result[0]);

  I don't have nsProfileDirServiceProvider wrapped in java so I can't test it right now

    // How about this?
    directoryService.RegisterProvider(result[0]);

  That doesn't appear to do anything.  Probably because I don't have an actual
  provider.  If I did have one, I could probably SetProfileDir on it.  Perhaps
  that is all that is needed.

  - other potential solution:  do I need to pass a
    nsProfileDirServiceProvider in the list of staticComponents?
  - are these bugs related?
    https://bugzilla.mozilla.org/show_bug.cgi?id=263799
    https://bugzilla.mozilla.org/show_bug.cgi?id=264096

[1]
0x04844aa0 in nsPasswordManager::Init (this=0x950ec08)
    at nsPasswordManager.cpp:290
290       mSignonFile->AppendNative(signonFile);
Current language:  auto; currently c++
(gdb) bt
#0  0x04844aa0 in nsPasswordManager::Init (this=0x950ec08)
    at nsPasswordManager.cpp:290
#1  0x04844c18 in nsPasswordManager::GetInstance ()
    at nsPasswordManager.cpp:233
#2  0x0481d9d8 in nsPasswordManagerConstructor (aOuter=0x0, aIID=@0x2e42cc0, 
    aResult=0xbf9e4a30) at nsToolkitCompsModule.cpp:79
#3  0x02de1c92 in nsGenericFactory::CreateInstance (this=0x950eb40, 
    aOuter=0x0, aIID=@0x2e42cc0, aResult=0xbf9e4a30) at nsGenericFactory.cpp:79
#4  0x02e18e09 in nsComponentManagerImpl::CreateInstanceByContractID (
    this=0x8ef5808, aContractID=0x950ebe0 "@mozilla.org/passwordmanager;1", 
    aDelegate=0x0, aIID=@0x2e42cc0, aResult=0xbf9e4a30)
    at nsComponentManager.cpp:1981
#5  0x02e19681 in nsComponentManagerImpl::GetServiceByContractID (
    this=0x8ef5808, aContractID=0x950ebe0 "@mozilla.org/passwordmanager;1", 
    aIID=@0x2e42cc0, result=0xbf9e4aa8) at nsComponentManager.cpp:2408
#6  0x02ddfb68 in CallGetService (
    aContractID=0x950ebe0 "@mozilla.org/passwordmanager;1", aIID=@0x2e42cc0, 
    aResult=0xbf9e4aa8) at nsComponentManagerUtils.cpp:94
#7  0x02ddfb91 in nsGetServiceByContractIDWithError::operator() (this=0x0, 
    aIID=@0xbf9e48b8, aInstancePtr=0x8ef4ae4)
    at nsComponentManagerUtils.cpp:288
#8  0x02ddf7f5 in nsCOMPtr_base::assign_from_gs_contractid_with_error (
    this=0xbf9e4b4c, gs=@0x0, iid=@0xbf9e48b8) at nsCOMPtr.cpp:141
#9  0x02e17093 in nsCOMPtr (this=0xbf9e4b4c, gs=@0xbf9e4b38)
    at dist/include/xpcom/nsCOMPtr.h:1006
#10 0x02e16a55 in NS_CreateServicesFromCategory (
    category=0x32e763c "passwordmanager", origin=0x0, 
    observerTopic=0x32e763c "passwordmanager") at nsCategoryManager.cpp:866
#11 0x03143679 in nsHTMLFormElement::AddElement (this=0x955de28, 
    aChild=0x950eae8) at nsHTMLFormElement.cpp:1217
#12 0x0312cc0c in nsGenericHTMLFormElement::SetAttr (this=0x950ead0, 
    aNameSpaceID=0, aName=0x8efc408, aPrefix=0x0, aValue=@0xbf9e4e30, 
    aNotify=0) at nsGenericHTMLElement.cpp:3361
#13 0x03153e04 in nsHTMLInputElement::SetAttr (this=0x950ead0, aNameSpaceID=0, 
    aName=0x8efc408, aPrefix=0x0, aValue=@0xbf9e4e30, aNotify=0)
    at nsHTMLInputElement.cpp:215
#14 0x02f895b3 in nsIContent::SetAttr (this=0x950ead0, aNameSpaceID=0, 
    aName=0x8efc408, aValue=@0xbf9e4e30, aNotify=0)
    at dist/include/content/nsIContent.h:284
#15 0x0317a492 in HTMLContentSink::AddAttributes (this=0x9072688, 
    aNode=@0x950e068, aContent=0x950ead0, aNotify=0, aCheckIfPresent=0)
    at nsHTMLContentSink.cpp:827
#16 0x0317b87e in SinkContext::AddLeaf (this=0x8f7f780, aNode=@0x950e068)
    at nsHTMLContentSink.cpp:1401
#17 0x0317ba99 in HTMLContentSink::AddLeaf (this=0x9072688, aNode=@0x950e068)
    at nsHTMLContentSink.cpp:3035
#18 0x04116a73 in CNavDTD::AddLeaf (this=0x8f670d8, aNode=0x950e068)
    at CNavDTD.cpp:3576
#19 0x04117e7f in CNavDTD::HandleDefaultStartToken (this=0x8f670d8, 
    aToken=0x9551078, aChildTag=eHTMLTag_input, aNode=0x950e068)
    at CNavDTD.cpp:1284
#20 0x04118154 in CNavDTD::HandleStartToken (this=0x8f670d8, aToken=0x9551078)
    at CNavDTD.cpp:1668
#21 0x041195e8 in CNavDTD::HandleToken (this=0x8f670d8, aToken=0x9551078, 
    aParser=0x8f6fa00) at CNavDTD.cpp:955
#22 0x04118bbb in CNavDTD::BuildModel (this=0x8f670d8, aParser=0x8f6fa00, 
    aTokenizer=0x90e1f38, anObserver=0x0, aSink=0x90726d4) at CNavDTD.cpp:458
#23 0x04125f3d in nsParser::BuildModel (this=0x8f6fa00) at nsParser.cpp:2140
#24 0x04127ace in nsParser::ResumeParse (this=0x8f6fa00, allowIteration=1, 
    aIsFinalChunk=1, aCanInterrupt=1) at nsParser.cpp:2007
#25 0x04124bdb in nsParser::ContinueInterruptedParsing (this=0x8f6fa00)
    at nsParser.cpp:1480
#26 0x030bfee2 in nsContentSink::ScriptEvaluated (this=0x9072688, aResult=0, 
    aElement=0x95aa698, aIsInline=0, aWasPending=1) at nsContentSink.cpp:276
#27 0x030c0197 in nsScriptLoaderObserverProxy::ScriptEvaluated (
    this=0x94e28f0, aResult=0, aElement=0x95aa698, aIsInline=0, aWasPending=1)
    at nsContentSink.cpp:134
#28 0x030fe50e in nsScriptLoader::FireScriptEvaluated (this=0x8f6e958, 
    aResult=0, aRequest=0x95615a8) at nsScriptLoader.cpp:708
#29 0x030feff1 in nsScriptLoader::ProcessRequest (this=0x8f6e958, 
    aRequest=0x95615a8) at nsScriptLoader.cpp:673
#30 0x03100b83 in nsScriptLoader::OnStreamComplete (this=0x8f6e958, 
    aLoader=0x95aa288, aContext=0x95615a8, aStatus=0, stringLen=343, 
    string=0x957d6a0 "document.write('<a target=\"_top\"
href=\"http://ad.doubleclick.net/click;h=v8/346e/0/0/%2a/x;46320853;0-0;0;13358359;255-0/0;18234891/18252786/1;;~sscs=%3fhttp://ad.doubleclick.net/jump/N1841.OSTG/B1764";...)
    at nsScriptLoader.cpp:1036
#31 0x05984c01 in nsStreamLoader::OnStopRequest (this=0x95aa288, 
    request=0x9585074, ctxt=0x95615a8, aStatus=0) at nsStreamLoader.cpp:134
#32 0x05996b29 in nsHTTPCompressConv::OnStopRequest (this=0x9581068, 
    request=0x9585074, aContext=0x95615a8, aStatus=0)
    at nsHTTPCompressConv.cpp:134
#33 0x059844f6 in nsStreamListenerTee::OnStopRequest (this=0x957d120, 
    request=0x9585074, context=0x95615a8, status=0
    at nsStreamListenerTee.cpp:65
#34 0x059e1314 in nsHttpChannel::OnStopRequest (this=0x9585048, 
    request=0x95a5b98, ctxt=0x0, status=0) at nsHttpChannel.cpp:4074
#35 0x05969cbd in nsInputStreamPump::OnStateStop (this=0x95a5b98)
    at nsInputStreamPump.cpp:506
#36 0x05969f5b in nsInputStreamPump::OnInputStreamReady (this=0x95a5b98, 
    stream=0x95a5a58) at nsInputStreamPump.cpp:343
#37 0x02e0d611 in nsInputStreamReadyEvent::EventHandler (plevent=0x95a5bf4)
    at nsStreamUtils.cpp:119
#38 0x02e20bfd in PL_HandleEvent (self=0x95a5bf4) at plevent.c:688
#39 0x02e20e86 in PL_ProcessPendingEvents (self=0x903af58) at plevent.c:623
#40 0x02e226b3 in nsEventQueueImpl::ProcessPendingEvents (this=0x903af10)
    at nsEventQueue.cpp:417
#41 0x03bdec16 in event_processor_callback (source=0x909e680, 
    condition=G_IO_IN, data=0xbf9e48b8) at nsAppShell.cpp:67
#42 0x0099a94d in g_io_channel_unix_get_fd () from /lib/libglib-2.0.so.0

[2]
NSSRWLock_LockRead (rwlock=0x0) at nssrwlk.c:212
212         PZ_Lock(rwlock->rw_lock);
(gdb) bt
#0  NSSRWLock_LockRead (rwlock=0x0) at nssrwlk.c:212
#1  0x07934a7d in SECMOD_GetReadLock (modLock=0x0) at pk11list.c:71
#2  0x07946f9c in PK11_TokenExists (type=1) at pk11slot.c:1904
#3  0x071764fb in ssl3_config_match_init (ss=0xb280c078) at ssl3con.c:636
#4  0x0717cdac in ssl2_ConstructCipherSpecs (ss=0xb280c078) at sslcon.c:206
#5  0x0718046d in ssl2_BeginClientHandshake (ss=0xb280c078) at sslcon.c:3007
#6  0x07182b75 in ssl_Do1stHandshake (ss=0xb280c078) at sslsecur.c:149
#7  0x071835c4 in ssl_SecureSend (ss=0xb280c078, 
    buf=0x9bc1508 "GET /bugzilla HTTP/1.1\r\nHost: bugzilla.redhat.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060918 Fedora/1.5.0.7-3.fc6 Firefox/1.5.0.7 pango-text\r\nAccept: text/xml,appl"..., len=432, flags=0) at sslsecur.c:1090
#8  0x07183773 in ssl_SecureWrite (ss=0xb280c078, 
    buf=0x9bc1508 "GET /bugzilla HTTP/1.1\r\nHost: bugzilla.redhat.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060918 Fedora/1.5.0.7-3.fc6 Firefox/1.5.0.7 pango-text\r\nAccept: text/xml,appl"..., len=432) at sslsecur.c:1128
#9  0x07186316 in ssl_Write (fd=0xb2800558, buf=0x9bc1508, len=432) at sslsock.c:1413
#10 0x03f72941 in nsSSLIOLayerWrite (fd=0x9e4e830, buf=0x9bc1508, amount=432) at nsNSSIOLayer.cpp:1148
#11 0x03bee03f in PR_Write () from /usr/lib/libnspr4.so
#12 0x03d6e298 in nsSocketOutputStream::Write (this=0xb280bda8, 
    buf=0x9bc1508 "GET /bugzilla HTTP/1.1\r\nHost: bugzilla.redhat.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060918 Fedora/1.5.0.7-3.fc6 Firefox/1.5.0.7 pango-text\r\nAccept: text/xml,appl"..., count=432, countWritten=0xb70d9288) at nsSocketTransport2.cpp:550
#13 0x03db449d in nsHttpConnection::OnReadSegment (this=0xb2801588, 
    buf=0x9bc1508 "GET /bugzilla HTTP/1.1\r\nHost: bugzilla.redhat.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060918 Fedora/1.5.0.7-3.fc6 Firefox/1.5.0.7 pango-text\r\nAccept: text/xml,appl"..., count=3071122480, countRead=0xb70d9288) at nsHttpConnection.cpp:524
#14 0x03dbc505 in nsHttpTransaction::ReadRequestSegment (stream=0x9b84210, closure=0x9bd9eb8, 
    buf=0x9bc1508 "GET /bugzilla HTTP/1.1\r\nHost: bugzilla.redhat.com\r\nUser-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060918 Fedora/1.5.0.7-3.fc6 Firefox/1.5.0.7 pango-text\r\nAccept: text/xml,appl"..., offset=0, count=432, countRead=0xb70d9288) at nsHttpTransaction.cpp:354
#15 0x02a30933 in nsStringInputStream::ReadSegments (this=0x9b84210, 
    writer=0x3dbc4ea <nsHttpTransaction::ReadRequestSegment(nsIInputStream*, void*, char const*, unsigned int, unsigned int, unsigned int*)>, closure=0x9bd9eb8, 
    aCount=163358640, result=0xb70d9288) at nsStringStream.cpp:240
#16 0x03dbda94 in nsHttpTransaction::ReadSegments (this=0x9bd9eb8, reader=0xb2801588, count=4096, countRead=0xb70d9288) at nsHttpTransaction.cpp:379
#17 0x03db3482 in nsHttpConnection::OnSocketWritable (this=0xb2801588) at nsHttpConnection.cpp:559
#18 0x03db36d5 in nsHttpConnection::OnOutputStreamReady (this=0xb2801588, out=0xb280bda8) at nsHttpConnection.cpp:770
#19 0x03d6b831 in nsSocketOutputStream::OnSocketReady (this=0xb280bda8, condition=0) at nsSocketTransport2.cpp:489
#20 0x03d6bd0a in nsSocketTransport::OnSocketReady (this=0xb280bca8, fd=0x9e4e830, outFlags=3) at nsSocketTransport2.cpp:1466
#21 0x03d70186 in nsSocketTransportService::Run (this=0x9bd82c0) at nsSocketTransportService2.cpp:582
#22 0x02a452d9 in nsThread::Main (arg=0x9bca730) at nsThread.cpp:118
#23 0x03c09d6d in PR_JoinThread () from /usr/lib/libnspr4.so
#24 0x00be23db in start_thread () from /lib/libpthread.so.0
#25 0x004a606e in clone () from /lib/libc.so.6

Attachment: pgpe8W40AyOja.pgp
Description: PGP signature


Back to the top