Problems using NS_InitXPCOM2 from xulrunner 13 and later

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems using NS_InitXPCOM2 from xulrunner 13 and later

Adam Dickmeiss-2
I'm trying to get NS_InitXPCOM2 to work . I have linked against xulrunner SDK's 10, 12, 13, 16 and 17. We also have other programs using XRE_InitEmbedding2, but the point of failure is the same.

#include <stdio.h>
#include "nsIServiceManager.h"
#include "nsXPCOM.h"
#include "nsCOMPtr.h"

int main(int argc, char **argv)
{
    nsresult rv;

    nsCOMPtr<nsIServiceManager> servMan;
#if MOZ_MAJOR > 16
    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
#else
    rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
#endif
    if (NS_FAILED(rv))
    {
        printf("NS_InitXPCOM2 failed . rv=%08x", (int) rv);
        return 1;
    }
    return 0;
}


adam@curry:~/proj/cf/engine/src$ gdb ./embed_test
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/adam/proj/cf/engine/src/embed_test...done.
(gdb) run
Starting program: /home/adam/proj/cf/engine/src/embed_test
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffeb690700 (LWP 11054)]
[New Thread 0x7fffeae8f700 (LWP 11055)]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff322f613 in PL_DHashTableOperate (table=0x62bcd8,
    key=0x7ffff3a9ccb0, op=PL_DHASH_LOOKUP)
    at /builds/slave/rel-m-beta-xr-lnx64-bld/build/obj-firefox/xpcom/build/pldhash.cpp:576
#2  0x00007ffff32555df in nsTHashtable<nsBaseHashtableET<nsIDHashKey, nsFactoryEntry*> >::GetEntry (this=<value optimized out>, aKey=<value optimized out>)
    at ../../dist/include/nsTHashtable.h:148
#3  0x00007ffff32555f9 in nsBaseHashtable<nsIDHashKey, nsFactoryEntry*, nsFactoryEntry*>::Get (this=<value optimized out>, aKey=<value optimized out>)
    at ../../dist/include/nsBaseHashtable.h:126
#4  0x00007ffff3256cf7 in nsComponentManagerImpl::RegisterCIDEntry (
    this=0x62bc70, aEntry=0x7ffff47ad0e0, aModule=0x656200)
    at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:423
#5  0x00007ffff3257b62 in nsComponentManagerImpl::RegisterModule (
    this=0x62bc70, aModule=0x7ffff45638f0, aFile=0x0)
    at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:397
#6  0x00007ffff3257ed9 in nsComponentManagerImpl::Init (this=0x62bc70)
    at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:347
#7  0x00007ffff32327f5 in NS_InitXPCOM2_P (result=0x7fffffffe260,
    binDirectory=<value optimized out>, appFileLocationProvider=0x0)
    at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/build/nsXPComInit.cpp:466
#8  0x0000000000400a80 in main (argc=1, argv=0x7fffffffe378)
    at embed_test.cpp:13

_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Reply | Threaded
Open this post in threaded view
|

Re: Problems using NS_InitXPCOM2 from xulrunner 13 and later

Mook-6
On 11/5/2012 10:58 AM, [hidden email] wrote:
> I'm trying to get NS_InitXPCOM2 to work . I have linked against xulrunner SDK's 10, 12, 13, 16 and 17. We also have other programs using XRE_InitEmbedding2, but the point of failure is the same.
<snip>

> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000000000 in ?? ()
> (gdb) bt
> #0  0x0000000000000000 in ?? ()
> #1  0x00007ffff322f613 in PL_DHashTableOperate (table=0x62bcd8,
>      key=0x7ffff3a9ccb0, op=PL_DHASH_LOOKUP)
>      at /builds/slave/rel-m-beta-xr-lnx64-bld/build/obj-firefox/xpcom/build/pldhash.cpp:576

bug 763327, perhaps?  The workaround I'm using is
http://hg.mozilla.org/pyxpcom/file/0ba416782345/xpcom/src/module/_xpcom.cpp#l278

You can probably use simpler things, since you are not a shared library
being loaded by some other process :)

HTH,

--
Mook

_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Reply | Threaded
Open this post in threaded view
|

Re: Problems using NS_InitXPCOM2 from xulrunner 13 and later

Zoltan Boszormenyi-3
In reply to this post by Adam Dickmeiss-2
2012. november 5., hétfő 19:58:08 UTC+1 időpontban [hidden email] a következőt írta:

> I'm trying to get NS_InitXPCOM2 to work . I have linked against xulrunner SDK's 10, 12, 13, 16 and 17. We also have other programs using XRE_InitEmbedding2, but the point of failure is the same.
>
>
>
> #include <stdio.h>
>
> #include "nsIServiceManager.h"
>
> #include "nsXPCOM.h"
>
> #include "nsCOMPtr.h"
>
>
>
> int main(int argc, char **argv)
>
> {
>
>     nsresult rv;
>
>
>
>     nsCOMPtr<nsIServiceManager> servMan;
>
> #if MOZ_MAJOR > 16
>
>     rv = NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
>
> #else
>
>     rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
>
> #endif
>
>     if (NS_FAILED(rv))
>
>     {
>
>         printf("NS_InitXPCOM2 failed . rv=%08x", (int) rv);
>
>         return 1;
>
>     }
>
>     return 0;
>
> }
>
>
>
>
>
> adam@curry:~/proj/cf/engine/src$ gdb ./embed_test
>
> GNU gdb (GDB) 7.0.1-debian
>
> Copyright (C) 2009 Free Software Foundation, Inc.
>
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>
> This is free software: you are free to change and redistribute it.
>
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>
> and "show warranty" for details.
>
> This GDB was configured as "x86_64-linux-gnu".
>
> For bug reporting instructions, please see:
>
> <http://www.gnu.org/software/gdb/bugs/>...
>
> Reading symbols from /home/adam/proj/cf/engine/src/embed_test...done.
>
> (gdb) run
>
> Starting program: /home/adam/proj/cf/engine/src/embed_test
>
> [Thread debugging using libthread_db enabled]
>
> [New Thread 0x7fffeb690700 (LWP 11054)]
>
> [New Thread 0x7fffeae8f700 (LWP 11055)]
>
>
>
> Program received signal SIGSEGV, Segmentation fault.
>
> 0x0000000000000000 in ?? ()
>
> (gdb) bt
>
> #0  0x0000000000000000 in ?? ()
>
> #1  0x00007ffff322f613 in PL_DHashTableOperate (table=0x62bcd8,
>
>     key=0x7ffff3a9ccb0, op=PL_DHASH_LOOKUP)
>
>     at /builds/slave/rel-m-beta-xr-lnx64-bld/build/obj-firefox/xpcom/build/pldhash.cpp:576
>
> #2  0x00007ffff32555df in nsTHashtable<nsBaseHashtableET<nsIDHashKey, nsFactoryEntry*> >::GetEntry (this=<value optimized out>, aKey=<value optimized out>)
>
>     at ../../dist/include/nsTHashtable.h:148
>
> #3  0x00007ffff32555f9 in nsBaseHashtable<nsIDHashKey, nsFactoryEntry*, nsFactoryEntry*>::Get (this=<value optimized out>, aKey=<value optimized out>)
>
>     at ../../dist/include/nsBaseHashtable.h:126
>
> #4  0x00007ffff3256cf7 in nsComponentManagerImpl::RegisterCIDEntry (
>
>     this=0x62bc70, aEntry=0x7ffff47ad0e0, aModule=0x656200)
>
>     at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:423
>
> #5  0x00007ffff3257b62 in nsComponentManagerImpl::RegisterModule (
>
>     this=0x62bc70, aModule=0x7ffff45638f0, aFile=0x0)
>
>     at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:397
>
> #6  0x00007ffff3257ed9 in nsComponentManagerImpl::Init (this=0x62bc70)
>
>     at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/components/nsComponentManager.cpp:347
>
> #7  0x00007ffff32327f5 in NS_InitXPCOM2_P (result=0x7fffffffe260,
>
>     binDirectory=<value optimized out>, appFileLocationProvider=0x0)
>
>     at /builds/slave/rel-m-beta-xr-lnx64-bld/build/xpcom/build/nsXPComInit.cpp:466
>
> #8  0x0000000000400a80 in main (argc=1, argv=0x7fffffffe378)
>
>     at embed_test.cpp:13

Just link with:

`pkg-config --libs libxul` -Wl,--whole-archive -lmozglue -lmemory -Wl,--no-whole-archive

This solved the problem for me recently.
_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding
Reply | Threaded
Open this post in threaded view
|

Re: Problems using NS_InitXPCOM2 from xulrunner 13 and later

Adam Dickmeiss-2

> Just link with:
>
>
>
> `pkg-config --libs libxul` -Wl,--whole-archive -lmozglue -lmemory -Wl,--no-whole-archive
>
>
>
> This solved the problem for me recently.

Works for me too. Thanks.
_______________________________________________
dev-embedding mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-embedding