Problem with static

Discussion in 'C' started by vijay_choudhari, Oct 24, 2007.

  1. vijay_choudhari

    vijay_choudhari New Member

    Joined:
    Oct 24, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I am getting coredump on linux (Red Hat 3.4.6-8).I am using gcc (GCC) 3.4.6 20060404 compiler. The problem is I have declared and used static map[i.e. STL] inside a function.This function is in say XYZ.so .Now at run time another host application is loading this XYZ.so, using it and then unloading it.Everything works fine,But when host application closes[i.e. exits] It is giving coredump.If we change static map to static vector then it works fine[no coredump while closing host application.].
    My questions are,
    1.Exactly when static variables in XYZ.so gets deallocated[After unloading XYZ.so or after exiting from main() of host apllication].

    2.STL grows at runtime if needed and variables marked as static gets space in .obj at compile time i.e. fixed amount of space[not absolute memory location but the offset].Then how does compiler handles allocation and deallocation of variables of type static STL[i.e. static map,vector,..].

    3.In our case host application crashes after exiting main[after unloading XYZ.so].It means static map is getting destructed after exiting main.It conflicts with 2nd point[allocation of space for static variable in .obj]

    4.Also if static variables which are from XYZ.so are getting destructed after exiting main() of host application and XYZ.so is already unloaded then how does host application gets access of the destructors of static type which are declared in XYZ.so .

    Could anybody please help me on this issue,Thanks in advance.

    Vijay
     
  2. deepak.mobisy

    deepak.mobisy New Member

    Joined:
    Oct 24, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    ya man u need not to worry abt that....
    its ok.
    u can ..try to solve this..
    this is a kind of stackoverflow..
    its require more memory.. :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice