[D-runtime] Runtime issue on Mac OS X
Jacob Carlborg
doob at me.com
Thu Jun 21 02:32:46 PDT 2012
On 21 jun 2012, at 02:02, Sean Kelly wrote:
> It can't be used if a dynamic library calls this function and is then later unloaded via dlclose. The easy way out would be to say that the result of calling dlclose on a Druntime dynamic library is undefined, and then put Druntime in its own dynamic library so random D dynamic libraries could be loaded and unloaded safely.
Yeah, that would be one idea. But what about dyld_register_image_state_change_handler?
> If you call dlopen for a library once, future dlopen calls will be effectively no-ops, right?
Yes, it will increment a counter. One needs to match all dlopen with a dlclose to be safe.
> One not great alternative would be to provide a function that registers a trampoline function in the calling process. I'd guess this would mean passing in the address of a static void* to hold this to rt_init() or something though.
>
> It's weird that there's no unregister function. Have you checked the darwin sources?
Yes, I've checked the source code for dyld (the dynamic loader). Again, what about dyld_register_image_state_change_handle? Using that function will work as proven by this example:
http://pastebin.com/qZfiWRbN
--
/Jacob Carlborg
More information about the D-runtime
mailing list