Closed Bug 340789 Opened 19 years ago Closed 7 years ago

libpyloader component can't be autoregistered from python

Categories

(Other Applications Graveyard :: PyXPCOM, defect)

1.8 Branch
x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: glandium, Unassigned)

References

Details

When running without persistent registry, and without write access to the components directory, pyxpcom fails: python2.3 -c 'from xpcom import components; print components.classes["@mozilla.org/file/local;1"]' No Persistent Registry Found. Type Manifest File: /usr/lib/xulrunner/components/xpti.dat ###!!! ASSERTION: Failed to write xpti manifest!: 'Error', file xptiInterfaceInfoManager.cpp, line 1937 Break: at file xptiInterfaceInfoManager.cpp, line 1937 *** Registering (...) components (all right -- a generic module!) nsNativeComponentLoader: autoregistering begins. *** Registering (...) components (all right -- a generic module!) nsNativeComponentLoader: autoregistering succeeded ###!!! ASSERTION: Failed to write xpti manifest!: 'Error', file xptiInterfaceInfoManager.cpp, line 1937 Break: at file xptiInterfaceInfoManager.cpp, line 1937 nsNativeComponentLoader: registering deferred (0) nsNativeComponentLoader: registering deferred (0) nsNativeComponentLoader: registering deferred (0) Traceback (most recent call last): File "<string>", line 1, in ? File "/usr/lib/python2.3/site-packages/xpcom/xpt.py", line 72, in ? import xpcom._xpcom File "/usr/lib/python2.3/site-packages/xpcom/server/__init__.py", line 40, in ? from policy import DefaultPolicy File "/usr/lib/python2.3/site-packages/xpcom/server/policy.py", line 38, in ? from xpcom import xpcom_consts, _xpcom, client, nsError, ServerException, COMException File "/usr/lib/python2.3/site-packages/xpcom/client/__init__.py", line 40, in ? from xpcom import xpt, COMException, nsError ImportError: cannot import name xpt When running without persistent registry, *with* write access to the components directory, pyxpcom fails when autoregistering: python2.3 -c 'from xpcom import components; print components.classes["@mozilla.org/file/local;1"]' No Persistent Registry Found. Type Manifest File: /usr/lib/xulrunner/components/xpti.dat *** Registering (...) components (all right -- a generic module!) nsNativeComponentLoader: autoregistering begins. *** Registering (...) components (all right -- a generic module!) nsNativeComponentLoader: autoregistering succeeded nsNativeComponentLoader: registering deferred (0) nsNativeComponentLoader: registering deferred (0) nsNativeComponentLoader: registering deferred (0) Traceback (most recent call last): File "<string>", line 1, in ? File "/usr/lib/python2.3/site-packages/xpcom/xpt.py", line 72, in ? import xpcom._xpcom File "/usr/lib/python2.3/site-packages/xpcom/server/__init__.py", line 40, in ? from policy import DefaultPolicy File "/usr/lib/python2.3/site-packages/xpcom/server/policy.py", line 38, in ? from xpcom import xpcom_consts, _xpcom, client, nsError, ServerException, COMException File "/usr/lib/python2.3/site-packages/xpcom/client/__init__.py", line 40, in ? from xpcom import xpt, COMException, nsError ImportError: cannot import name xpt But one the persistent registry has been created, it is ok (i.e. running the same right after the previous autoregistration process): python2.3 -c 'from xpcom import components; print components.classes["@mozilla.org/file/local;1"]' Type Manifest File: /usr/lib/xulrunner/components/xpti.dat <xpcom.components._Class instance at 0xa7de4bac> With or without write access to the components directory, xpconnect and javaxpcom don't fail like that.
By adding a breakpoint on PyErr_NormalizeException I got an interesting backtrace on a non-raised exception that happens after the last *** Registering (...) components (all right -- a generic module!) and nsNativeComponentLoader: autoregistering succeeded #0 PyErr_NormalizeException (exc=0xafb2d134, val=0xafb2d130, tb=0xafb2d12c) at ../Python/errors.c:128 #1 0xa7909922 in PyXPCOM_LogError (fmt=0xa7929654 "Obtaining the module object from Python failed.\n") at ErrorUtils.cpp:94 #2 0xa7921eb3 in PyXPCOM_NSGetModule (servMgr=0x80ab3a8, location=0x8103ab8, result=0x8103b88) at xpcom.cpp:137 #3 0xa5ab1032 in NSGetModule (servMgr=0x80ab3a8, location=0x8103ab8, result=0x8103b88) at pyloader.cpp:230 #4 0xa69aa4b4 in nsDll::GetModule (this=0x8103b80, servMgr=0x80ab3a8, cobj=0xafb2d680) at xcDll.cpp:249 #5 0xa69a6e25 in nsNativeComponentLoader::SelfRegisterDll (this=0x80b8538, dll=0x8103b80, registryLocation=0x80ab550 "rel:libpyloader.so", deferred=0) at nsNativeComponentLoader.cpp:407 #6 0xa69a7b7c in nsNativeComponentLoader::AutoRegisterComponent (this=0x80b8538, when=0, component=0x8103ab8, registered=0xafb2d95c) at nsNativeComponentLoader.cpp:880 #7 0xa69a5a86 in nsNativeComponentLoader::RegisterComponentsInDir (this=0x80b8538, when=0, dir=0x80c0f70) at nsNativeComponentLoader.cpp:242 #8 0xa69a546a in nsNativeComponentLoader::AutoRegisterComponents (this=0x80b8538, aWhen=0, aDirectory=0x80c0f70) at nsNativeComponentLoader.cpp:182 #9 0xa69a287f in nsComponentManagerImpl::AutoRegisterImpl (this=0x80ab3a8, when=0, inDirSpec=0x0, fileIsCompDir=1) at nsComponentManager.cpp:3191 #10 0xa69a2d46 in nsComponentManagerImpl::AutoRegister (this=0x80ab3a8, aSpec=0x0) at nsComponentManager.cpp:3404 #11 0xa69395c7 in NS_InitXPCOM3_P (result=0x0, binDirectory=0x0, appFileLocationProvider=0x0, staticComponents=0xa78519a0, componentCount=37) at nsXPComInit.cpp:608 #12 0xa6939b63 in NS_InitXPCOM2_P (result=0x0, binDirectory=0x0, appFileLocationProvider=0x0) at nsXPComInit.cpp:447 #13 0xa7922ebc in PyXPCOM_Globals_Ensure () at xpcom.cpp:551 #14 0xa7922f3f in init_xpcom () at xpcom.cpp:587 Looking at the code, I should see this error through the console service, but i don't know where it is supposed to be logged...
in xpcom.cpp, line 121: PyObject *mod = PyImport_ImportModule("xpcom.server"); return NULL... It seems NSGetModuling libpyloader from python doesn't work very well...
The only thing I would say to you is reinstall firefox, possible a missing file.
Summary: Can't use pyxpcom when component registration is not done beforehand → libpyloader component can't be autoregistered from python
My guess is that python can't load xpcom.xpt because it's the file being processed when doing the pyxpcom initialization, thus the autoregistration when required. If the pyxpcom initialization was done by the python program calling pyxpcom and not by the library, it would work, i guess. I think the problem would disappear when pyxpcom switches to using the xpcom glue like javaxpcom does. Anyone to confirm ?
(and the exception i caught with gdb is actually raised. it is the one i got in the first place)
Workaround: It works if you import _xpcom first: python2.3 -c 'from xpcom import _xpcom, components; print components.classes["@mozilla.org/file/local;1"]'
Well this seems to be only you. Well to have this solve re-install firefox.
(In reply to comment #7) > Well this seems to be only you. Well to have this solve re-install firefox. > You seem to not understand the issue.
Component: XPCOM → PyXPCOM
Product: Core → Other Applications
QA Contact: xpcom → pyxpcom
Component is obsolete so resolving bugs as INCOMPLETE[B
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
Product: Other Applications → Other Applications Graveyard
You need to log in before you can comment on or make changes to this bug.