weird segmentation fault

buptstehcbuptstehc chuan huangOrganization: CISDI Information Technology Co., LtdProject: protocol adapterMember
hi, all! My app crashes receiving sigsegv signal when starts. This is the output from gdb:

#0 0x009e8649 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const () from /usr/lib/i386-linux-gnu/libstdc++.so.6
...
#6 0x0034b85b in IceInternal::FactoryTable::addObjectFactory (this=0x81252f8, t=..., f=...) at FactoryTable.cpp:96
#7 0x0090beda in __F__jupiter__JRequest__Init () at ../jbase.cpp:322
#8 __static_initialization_and_destruction_0 () at ../jbase.cpp:331
#9 global constructors keyed to jbase.cpp(void) () at ../jbase.cpp:647
#10 0x00939f6d in __do_global_ctors_aux () from /home/henry/Work/jupiter/comm/dll/.libs/libjuserclass.so.0
#11 0x00907f40 in _init () from /home/henry/Work/jupiter/comm/dll/.libs/libjuserclass.so.0

libjuserclass is a dll, and JRequest is a class defined in jbase.ice.
//jbase.ice
module jupiter {
// Protocols supportted for now.
enum JCommType {
//...
};

// Since hub is stateless, you must tell hub what do you want.
enum JAction {
//...
};

// All requests sending to hub must subclass from this.
class JRequest {
JCommType type; //type of communication
JAction act; //name of calling method
};

// All classes receiving from hub must subclass from this.
class JResponse {
bool success = true;
};
};
#endif

The weird thing is the app crashes before calling the function referenced from the dll. please help!

Comments

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice DeveloperAdministrators, ZeroC Staff ZeroC Staff
    Hi,

    Can you provide an small test case that reproduce the problem? that will be easier way to know what is happening.

    We need to know the OS, Compiler and Ice versions.

    Can you post the complete stack trace?
    The weird thing is the app crashes before calling the function referenced from the dll. please help!

    That is a problem with static initializations, so don't need to call any functions.

    Regards,
    Jose
  • buptstehcbuptstehc chuan huangOrganization: CISDI Information Technology Co., LtdProject: protocol adapterMember
    xdm wrote: »
    Hi,

    Can you provide an small test case that reproduce the problem? that will be easier way to know what is happening.

    We need to know the OS, Compiler and Ice versions.

    Can you post the complete stack trace?



    That is a problem with static initializations, so don't need to call any functions.

    Regards,
    Jose

    Thanks for the reply. Since my app is a little complex, it is not very convenient to paste my code here. this my env:
    os: ubuntu 11.04
    compiler: g++ 4.5.2
    ice:3.4.1
    this the entire output from gdb:

    ***********************************gdb output**************************************
    Program received signal SIGSEGV, Segmentation fault.
    0x0098a56a in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
    (gdb) bt
    #0 0x0098a56a in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/i386-linux-gnu/libstdc++.so.6
    #1 0x0034ca4b in std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::pair<IceInternal::Handle<Ice::ObjectFactory>, int> >::pair (this=0xbfffefb0, __a=..., __b=...) at /usr/include/c++/4.5/bits/stl_pair.h:88
    #2 0x0034c1d2 in std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<IceInternal::Handle<Ice::ObjectFactory>, int>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::pair<IceInternal::Handle<Ice::ObjectFactory>, int> > > >::operator[] (this=0x8125328, __k=...) at /usr/include/c++/4.5/bits/stl_map.h:451
    #3 0x0034b8c1 in IceInternal::FactoryTable::addObjectFactory (this=0x81252f8, t=..., f=...) at FactoryTable.cpp:99
    #4 0x008e638a in __F__jupiter__JRequest__Init () at ../jbase.cpp:322
    #5 __static_initialization_and_destruction_0 () at ../jbase.cpp:331
    #6 global constructors keyed to jbase.cpp(void) () at ../jbase.cpp:647
    #7 0x008f307d in __do_global_ctors_aux () from /home/henry/Work/jupiter/comm/dll/.libs/libjuserclass.so.0
    #8 0x008e2f2c in _init () from /home/henry/Work/jupiter/comm/dll/.libs/libjuserclass.so.0
    #9 0x0011e64c in ?? () from /lib/ld-linux.so.2
    #10 0x0011e769 in ?? () from /lib/ld-linux.so.2
    #11 0x0011088f in ?? () from /lib/ld-linux.so.2
    ***********************************gdb output**************************************
    and this the slice file 'jbase.ice':
    ***********************************jbase.ice**************************************
    #ifndef __JBASE_ICE__

    #define __JBASE_ICE__



    module jupiter {

    // Protocols supportted for now.

    enum JCommType {

    kActiveSocket,

    kPassiveSocket,

    kOpc,

    kMq

    };



    // Since hub is stateless, you must tell hub what do you want.

    enum JAction {

    kOpcReadItem,

    kOpcReadItemByGroup,

    kOpcWriteItem,

    kOpcCreateGroup,

    kOpcRemoveGroup,

    kOpcServers,

    kOpcListItems,

    kActiveSocketSend,

    kActiveSocketReceive,

    kPassiveSocketSend,

    kMqSend,

    kMqReceive

    };



    // All requests sending to hub must subclass from this.

    class JRequest {

    JCommType type; //type of communication

    JAction act; //name of calling method

    };



    // All classes receiving from hub must subclass from this.

    class JResponse {

    bool success = true;

    };



    // All classes sending to hub must subclass from this.

    class JUserClassReq {

    };

    };

    #endif
    ***********************************jbase.ice**************************************
    It seems that the app crashes when initializing the global object. In addition, my app runs very well in vs studio 2008.
  • bernardbernard Jupiter, FLBernard NormierOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff
    The global object that is not initialized (but should be) is apparently the IceInternal::factoryTable.

    The registration that fails is triggered by the presence of Slice classes in your Slice; beyond that, I don't expect these definitions matter.

    The best would be to post a small test-case that reproduces this problem, with its build system.

    Best regards,
    Bernard
  • buptstehcbuptstehc chuan huangOrganization: CISDI Information Technology Co., LtdProject: protocol adapterMember
    bernard wrote: »
    The global object that is not initialized (but should be) is apparently the IceInternal::factoryTable.

    The registration that fails is triggered by the presence of Slice classes in your Slice; beyond that, I don't expect these definitions matter.

    The best would be to post a small test-case that reproduces this problem, with its build system.

    Best regards,
    Bernard

    i have solved this problem. the cause is that the app linked 'jbase.o' which has been linked in the dll. thanks all!
Sign In or Register to comment.