Home Help Center

sigsegv issue with std::string vars generated with slice

Jaime SilvaJaime Silva Member Jaime SilvaOrganization: Ingenieria de Software BancarioProject: Monitor our middleware platform
Hello, have an issue with global static variables generated by slice2cpp

when i create my .ice and compiled with slice, some .cpp file is generated with a list of global variables of type

static const ::std::string __mymodule__myclass__mymethod_name = "mymethod";


when i run in linux, my server fails with SIGSEGV in

#0 IceDelegateM::mymodule::myclass::mymethod (this=0x810f1f0, id=...,
flgRegister=0, prxInstance=..., __context=0x0) at mymodule.cpp:1199
#1 0xf794f96b in IceProxy::mymodule::myclass::mymethod (this=0x8111840,
id=..., flgRegister=0, prxInstance=..., __ctx=0x0) at mymodule.cpp:145
#2 0xf79675c8 in IceProxy::mymodule::myclass::mymethod (this=0x8111840,
id=..., flgRegister=0, prxInstance=...) at ./mymodule.h:196
#3 0xf7969a63 in Server::run (this=0xf6a28358, argc=2, argv=0xffffd784)
at Server.cpp:141
#4 0x009a55a8 in Ice::Application::doMain(int, char**, Ice::InitializationData const&) () from /usr/lib/libIce.so.34
#5 0x009a6577 in Ice::Application::main(int, char**, Ice::InitializationData const&) () from /usr/lib/libIce.so.34
#6 0xf796b3f1 in InstanceThread::run (this=0x8105960) at Server.cpp:259
#7 0x0031d7ce in ?? () from /usr/lib/libIceUtil.so.34
#8 0x002a1832 in start_thread () from /lib/libpthread.so.0
#9 0x0021fe0e in clone () from /lib/libc.so.6
(gdb)

the reason is those static const variables generated by slice remains NULL in runtime

(gdb) p __mymodule__myclass__mymethod_name
$3 = {static npos = 4294967295,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x0}}
(gdb)


I read this suppose to be a compiler/linker issue, so any hint will be apreciated to assure those static variables will initialize correctly, like some flag to compile a dynamic library with ice on it. I made lot of changes, like dlopen or link static, research compiler and linker flags. Nothing works and drive me crazy.

My program is a legacy C server and links with ICe by a dinamic library written in C++ with Ice methodology.

In Windows all works fine.
linux info:

uname -a
Linux myserver 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

ice 3.4.2

gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)


Thanks and regards

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    seems that C++ static initialization is failing for some reason, are you compiling your code with gcc? If that is the case try to use g++ instead.
  • Jaime SilvaJaime Silva Member Jaime SilvaOrganization: Ingenieria de Software BancarioProject: Monitor our middleware platform
    well, we cannot compile our server because strict style required by g++.

    however i made a little main() only to call the ICE based lib and the behavior is the same with g++
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Can you attach a simple test case to reproduce the problem.

    Regard,
    Jose
  • Jaime SilvaJaime Silva Member Jaime SilvaOrganization: Ingenieria de Software BancarioProject: Monitor our middleware platform
    Solved!
    I install the samples from Ice and made a makefile to generate a dinamic library (Icegrid I think).
    Some flags in the linker make the difference and copy one of your sample makefiles to create my own makefile to compile my code.
    Thank you for your support!
Sign In or Register to comment.