![]() |
| | #1 |
| Registered User Join Date: Nov 2008
Posts: 1
| Segmentation fault problem i have a problem with my .so . i am dynamically loading and unloading my libtemp.so using the dlopen and dlclose functions. my .so contains many global instances of many classes. i can see that all my global constructors are called on load and all my destructors are called on unload. everything seems fine. but when my program ends, i get a segmentation fault error. here is my main.cpp: Code: int main( int argc, char * argv[] )
{
if( argc != 2 ){
printf("usage [so name] \n");
return 0;
}
printf("Before Load\r\n");
void* pHandle = dlopen(argv[1]);
if( pHandle == NULL ){
printf("%s\r\n", dlerror());
}else{
printf("Load: Went fine\r\n");
if( dlclose(pHandle) ){
printf("UnLoad Went Ok\r\n");
}else{
printf("UnLoad Failed\r\n");
}
}
return 0;
}
Before Load Load: Went fine UnLoad Went Ok Segmentation fault when debugging, i can see that my main reached it's ending, but still i get the segmentation fault error. what might caused the problem ? is it some memory leak ? one of my globals problems ? i will appreciate any help, cause i am kind of lost here. thanks |
| odedbobi is offline | |
| | #2 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| You are supposed to pass two parameters to dlopen - not doing so could cause all sorts of different problems. Also, your destructors are called on dlclose(), so you if you are accessing memory that isn't valid from the destructors, it will cause a seg fault. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Segmentation fault ith g_type_check_class_cast () from /usr/lib/libgobject-2.0.so.0 | lehe | Game Programming | 7 | 02-02-2009 07:27 AM |
| Strange segmentation fault | Ron | C Programming | 24 | 06-15-2008 02:10 PM |
| Segmentation Fault hmm? | pobri19 | C Programming | 4 | 05-03-2008 07:51 AM |
| Re: Segmentation fault | turkish_van | C Programming | 8 | 01-20-2007 05:50 PM |
| [C++] Segmentation Fault {Novice C++ Programmer} | INFERNO2K | C++ Programming | 24 | 06-08-2005 07:44 PM |