Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Problem with static (http://www.go4expert.com/forums/problem-with-static-t7004/)

vijay_choudhari 24Oct2007 17:59

Problem with static
 
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

deepak.mobisy 24Oct2007 22:11

Re: Problem with static
 
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.. :)


All times are GMT +5.5. The time now is 13:40.