Operating System - HP-UX
1830624 Members
2375 Online
110015 Solutions
New Discussion

Problems with unloading a dynamically loaded library

 
SOLVED
Go to solution

Problems with unloading a dynamically loaded library

I am writing a program on HP-UX 11.11 which does the following:

a) dynamically load the library, and get the various function pointers
b) invoke some of the functions
c) unload the library

Somehow i can run throught this once, but the second time the program coredumps. At the time of coredump, one of the functions in the dynamically loaded library got into a recursion loop and out-ran the program stack size.

Another developer who had experience with dynamic loading says that some unix do not like the unload part.

Furthermore, the unload would unload the whole library, no matter how many 'load' was done, or whether the library was loaded dynamically or not.

The program is written in C++ but calls into a C library by dynamically loading it.

For timebeing, i commented out the unload part, but that is not a permanent solution. Are there any issues like this known on HP-UX?
2 REPLIES 2
Stephen Keane
Honored Contributor
Solution

Re: Problems with unloading a dynamically loaded library

Are you using dlopen/dlclose or shl_load/shl_unload?

Are you compiling 32-bit or 64-bit?

The same shared library can be opened multiple times.

On PA32, shl_unload unloads the shared library regardless of whether there are other references to it through other load invocations or through implicit references from other shared libraries. No reference count is kept.

On PA64, a reference counter is kept for each loaded shared library, like the behavior of dlopen(3c) and dlclose(3c). shl_unload does not remove the shared library from the address space until all references to that shared library have been removed.

Re: Problems with unloading a dynamically loaded library

It looks like this 32-bit behaviour is the reason for our issue. We have avoided the unloading and the program works fine now.