Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch of byterun/unix.c to bring native runtime inline with bytecode in regards to plugin reloading #7893

Open
vicuna opened this Issue Jan 5, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@vicuna
Copy link
Collaborator

vicuna commented Jan 5, 2019

Original bug ID: 7893
Reporter: progman
Status: new
Resolution: open
Priority: normal
Severity: minor
Platform: rpi3
OS: raspbian
OS Version: debian 18
Version: 4.07.1
Category: dynlink and natdynlink
Monitored by: @nojb @hcarty

Bug description

*** unix.c.dlltest	2019-01-05 07:26:44.459916955 +0000
--- unix.c	2019-01-05 08:22:05.729915688 +0000
***************
*** 273,278 ****
--- 273,282 ----
  
  void * caml_dlopen(char * libname, int for_execution, int global)
  {
+   //check whether already loaded
+   void* handle= dlopen(libname, RTLD_NOW | RTLD_NOLOAD);
+   if(handle)//it is so unload first as code is not otherwise actually loaded again
+     if(dlclose(handle) || dlclose(handle)) return NULL;
    return dlopen(libname, RTLD_NOW | (global ? RTLD_GLOBAL : RTLD_LOCAL));
    /* Could use RTLD_LAZY if for_execution == 0, but needs testing */
  }
@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jan 5, 2019

Comment author: progman

bytecode plugins can be edited, re-compiled and re-loaded into a running program.
with native the operation appears successful but does not in fact reload the
code.
the patch checks for presence of said plugin and unloads it to ensure
a code refresh.
two dlclose()'s are required (docs say 1 close each open, and RTLD_NOLOAD still
(in practice) increments the plugin reference count, hence two)

@vicuna vicuna added the dynlink label Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.