Dynamic libraries are not closed on MacOS X [with patch]

View: New views
2 Messages — Rating Filter:   Alert me  

Dynamic libraries are not closed on MacOS X [with patch]

by Paul Guyot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

On MacOS X, dynamic libraries opened with erl_ddll:load or  
load_driver are not closed when erl_ddll:unload/unload_driver is called.

Steps to reproduce:
* build a simple dynamic library, called simple_drv.so
* start a new erlang shell in the same directory.
* note down the PID.
* evaluate erl_ddll:load(".", "simple_drv").
* run lsof -p <PID> to see that indeed simple_drv.so file is open.
* evaluate erl_ddll:unload("simple_drv").
* run lsof -p <PID> to see that simple_drv.so file is still open.

This is specific to MacOS X and this is simply because the code  
hasn't been written. On other Unix implementations, the erl_ddll code  
calls dlopen and dclose.

The attached patch against R12B-4 fixes the bug and was tested on  
MacOS X 10.4/ppc.

Regards,

Paul






_______________________________________________
erlang-bugs mailing list
erlang-bugs@...
http://www.erlang.org/mailman/listinfo/erlang-bugs

patch-erts_emulator_sys_unix_ddll.c (834 bytes) Download Attachment

Re: Dynamic libraries are not closed on MacOS X [with patch]

by Bjorn Gustavsson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/9/7 Paul Guyot <pguyot@...>
Hello,

On MacOS X, dynamic libraries opened with erl_ddll:load or load_driver are not closed when erl_ddll:unload/unload_driver is called.

Steps to reproduce:
* build a simple dynamic library, called simple_drv.so
* start a new erlang shell in the same directory.
* note down the PID.
* evaluate erl_ddll:load(".", "simple_drv").
* run lsof -p <PID> to see that indeed simple_drv.so file is open.
* evaluate erl_ddll:unload("simple_drv").
* run lsof -p <PID> to see that simple_drv.so file is still open.

This is specific to MacOS X and this is simply because the code hasn't been written. On other Unix implementations, the erl_ddll code calls dlopen and dclose.

The attached patch against R12B-4 fixes the bug and was tested on MacOS X 10.4/ppc.

Thanks for your patch.

It works fine, but we will use the simpler solution of using dlopen() on all platforms:

http://www.erlang.org/pipermail/erlang-patches/2008-September/000293.html

/Bjorn

--
Björn Gustavsson, Erlang/OTP, Ericsson AB

_______________________________________________
erlang-bugs mailing list
erlang-bugs@...
http://www.erlang.org/mailman/listinfo/erlang-bugs
LightInTheBox - Buy quality products at wholesale price!