Eryk Sun <eryk...@gmail.com> added the comment:

> FWIW, the method does not exist on Windows

In Windows it's FreeLibrary, for which the implementation in NT calls loader 
and runtime library functions such as LdrUnloadDll and RtlImageNtHeaderEx. 
These OS functions internally use structured exception handling (SEH) to retun 
status codes such as STATUS_DLL_NOT_FOUND and STATUS_INVALID_IMAGE_FORMAT 
instead of crashing the process when passed an invalid module handle (i.e. 
module base address).

For POSIX, I don't see what can be done to avoid a crash when dlclose is passed 
a bad handle (i.e. module address). We can check for NULL, the obvious case, 
but otherwise AFAIK we can only detect an invalid address by trying to access 
it, which triggers a segfault. This is the reason that dlclose is only 
available in the private _ctypes module, and ctypes itself never even calls it.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34840>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to