-
Notifications
You must be signed in to change notification settings - Fork 50
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
add environment variable to avoid RTLD_DEEPBIND
when loading modules
#6063
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. I just wonder about the need for flux_deepbind()
in the public API.
Also, I wonder if the result of getenv ()
could be cached so we don't check multiple times for an environment variable that will almost never be present (or that could just be premature optimization)
bbfad5a
to
1ae99f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One nit inline, but otherwise seems good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of style nits but o/w LGTM too
src/common/libflux/plugin.c
Outdated
@@ -34,6 +36,21 @@ | |||
#define UUID_STR_LEN 37 // defined in later libuuid headers | |||
#endif | |||
|
|||
static int use_deepbind = 1; | |||
static pthread_once_t deepbind_once = PTHREAD_ONCE_INIT; | |||
static void init_use_deepbind () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: void parameter, open brace on new line
src/common/libflux/plugin.c
Outdated
} | ||
|
||
int plugin_deepbind () { | ||
pthread_once(&deepbind_once, init_use_deepbind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: open brace for function on new line, space before open paren in pthread_once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grondo - all your changes/fixes are great. I'll approve based on that and you can add yours once you feel like this is ready.
I think that's all addressed. |
src/common/libflux/plugin_private.h
Outdated
#ifndef FLUX_CORE_PLUGIN_PRIVATE_H | ||
#define FLUX_CORE_PLUGIN_PRIVATE_H | ||
|
||
int plugin_deepbind (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: add void param here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
RTLD_DEEPBIND
when loading modules
Restarted the inception builder which had failed. I could not discern why. |
problem: I recently needed to get a heap trace of flux to track down why fluxion was using so much memory, that's another sordid tale I'm afraid, but every tool I tried reported freeing unallocated pointers. There is a bad interaction between recent versions of glibc, that removed the allocator hooks, and the RTLD_DEEPBIND flag. Essentially it's nearly impossible to consistely replace the allocator interface in all the libraries consistently, whether using LD_PRELOAD or anything else. Thankfully just turning that off works, as long as we don't have symbol conflicts. solution: Replace use of FLUX_DEEPBIND with calls to `flux_deepbind ()` which checks for an environment variable, `FLUX_LOAD_WITH_DEEPBIND`, and if that variable is both set and contains 0 returns 0, otherwise it returns FLUX_DEEPBIND. This allows for easy flipping to load flux using say jemalloc, tcmalloc or the interposer library for heaptrack without a rebuild.
problem: spellcheck failed on the explanation of the deepbind environment variable solution: add appropriate tokens to dictionary
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6063 +/- ##
==========================================
- Coverage 83.34% 83.31% -0.03%
==========================================
Files 521 521
Lines 84389 84396 +7
==========================================
- Hits 70330 70317 -13
- Misses 14059 14079 +20
|
Add an environment variable to control whether we actually apply the RTLD_DEEPBIND flag when calling dlopen. More details in the commit message, but this makes it possible to run flux with an alternate allocator using LD_PRELOAD or certain other things that make heap tracing and certain other debugging and tracing tasks much easier.