Discussion:
[omniORB] omniORB client segfaults depending on the order in which object files are linked
Jacob Rief
2006-11-01 03:29:33 UTC
Permalink
Hi to everybody,

I found an interesting phenomena while I modified the code of
omniORB example eg2.
Depending on the order in which two object files are linked into a
dynamic shared object, either the example works or it segfaults.

To review the code please use this link http://svn.serles.com/omni_eg2/
and read the README for further details.

Regards,
Jacob
Duncan Grisby
2006-11-16 16:55:37 UTC
Permalink
Post by Jacob Rief
I found an interesting phenomena while I modified the code of
omniORB example eg2.
Depending on the order in which two object files are linked into a
dynamic shared object, either the example works or it segfaults.
To review the code please use this link http://svn.serles.com/omni_eg2/
and read the README for further details.
The problem is that you are calling ORB_init() and using _narrow inside
the initialiser function that is executed at library load time. The
omniORB stubs use C++ static initialisers for various things, and they
use the same mechanism to execute at library load time. Depending on the
link order, the stub initialisers may or may not have run before the
initialiser you wrote.

The safe solution is to move your initialisation code out of the init
function, and only run it after the library is completely loaded.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...