Statically linked application with multiple dlopen() crashes

[email protected] Fri, 12 Sep 2003 00:04:59 -0500
Newsgroups gmane.linux.redhat.release.psyche
Message-ID <4D7D6CB5232DA64A9346815A795B324E010314B6@blrx2kmbgl102.blr.amer.dell.com>
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
[email protected]
https://www.redhat.com/mailman/listinfo/psyche-list