(Function) pointers after plugin unload

closed account (G8CRjE8b)
Hi,
I have a highly dynamic plugin system with a lot of shared function/memory pointers.
Each plugin can rely on other (compile time linked) libraries and also shares data with them.

If I unload one plugin x other libraries might also unload.
Now I have a lot of invalid function/memory pointers.
Each pointer I always store with a piece of library info.
This info is used in Windows to clean up after an unload.
Windows also provides a Win32 library load/unload callback function (see LDRREGISTERDLLNOTIFICATION).

1. Linux/Unix systems seem not to have a library load/unload callback function, do they?

2. What happens if you call a function pointer of an unloaded library?
(Memory pointer should still be valid, shouldn't they?)

Thing is, I can not wait until a library is unloaded and then cleanup the pointers (via library info check). (Other threads might use those invalids in the meantime.)
But I also can not clean up before I unload because I don't know all depending libraries.

3. How and when can I clean up those pointers on Linux/Unix?


Habor
Linux/Unix systems seem not to have a library load/unload callback function, do they?
No.

Memory pointer should still be valid, shouldn't they?
Why not?

Thing is, I can not wait until a library is unloaded and then cleanup the pointers (via library info check). (Other threads might use those invalids in the meantime.)
But I also can not clean up before I unload because I don't know all depending libraries.
Why isn't the code that calls unload not resetting the function pointers to NULL?
closed account (G8CRjE8b)
-Memory pointer should still be valid, shouldn't they?-
Why not?

On Windows each library has its own memory, so to speak. If the library unloads the memory is invalid. ;)
But calling invalid function pointers will lead to crashes anyway, I assume.

Why isn't the code that calls unload not resetting the function pointers to NULL?

Example:
Plugin A uses library C
Plugin B uses library C, too

If I unload A I can not be sure C unloads too/I don't even know about C (in a generic system).
The Windows callback tells me about A, B AND C independently.
So how am I gonna do this on Linux?
Last edited on
Topic archived. No new replies allowed.