Statically linked application with multiple dlopen() crashes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All,

   I have an application which is statically linked.
It uses dlopen() and dlclose() calls multiple times.
First time the dlopen()/dlclose() pair succeeds.
But the second one fails with segfault.

 This happens only in RH AS2.1, not in RH 8.x/9.x
Any bug in glibc?

Any ideas?


Thanks.

--T. Muthu Mohan.

-----------[ source code: mystatic.cpp ]------------------
#include <iostream.h> 
#include <dlfcn.h> 
#include <stdlib.h> 
int main() 
{
	void *pHandle = dlopen("libz.so", RTLD_NOW);
	if (pHandle) {
		cout << "Successfully Loaded!" << endl;
		dlclose(pHandle);
		cout << "Successfully UnLoaded!" << endl;
	}

	cout << "Second Time" << endl;

	void *pHandle1 = dlopen("libz.so", RTLD_NOW);
	if (pHandle1) {
		cout << "Successfully Loaded!" << endl;
		dlclose(pHandle1);
		cout << "Successfully UnLoaded!" << endl;
	}
        return 0;
}
	
---------------
Compile using : g++ -g -static mystatic.cpp -o mystatic -ldl
                
Then run: ./mystatic
Successfully Loaded!
Successfully UnLoaded!
Second Time
Segmentaion Fault



-- 
Psyche-list mailing list
Psyche-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux