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

glibc 2.34 enablement around pthread mutex handling #2913

Closed
fweimer-rh opened this issue Jul 6, 2021 · 4 comments
Closed

glibc 2.34 enablement around pthread mutex handling #2913

fweimer-rh opened this issue Jul 6, 2021 · 4 comments

Comments

@fweimer-rh
Copy link
Contributor

src/preload/overrides.c contains this code:

/*
 * We need to able to call directly to __pthread_mutex_lock and
 * __pthread_mutex_trylock because setting up indirect function pointers
 * in init_process requires calls to dlsym which itself can call
 * pthread_mutex_lock (e.g. via application code overriding malloc/calloc
 * to use a pthreads-based implementation). So before our pointers are set
 * up, call these.
 */
extern int __pthread_mutex_lock(pthread_mutex_t* mutex);
extern int __pthread_mutex_trylock(pthread_mutex_t* mutex);

I want to remove most of the __-prefixed functions from the glibc 2.34 release. The above symbols would become unavailable for linking. Based on the comment, that should not be a problem because you can use RTLD_NEXT on glibc 2.34: dlsym uses an internal direct call to pthread_mutex_lock, without going through dynamic linking.

Would you be open to making this change? Fedora rawhide (available as a container image on registry.fedoraproject.org/fedora:rawhide) already contains a glibc 2.34 snapshot, if you want to experiment with it. Thanks.

@rocallahan
Copy link
Collaborator

Thanks for the heads-up! I guess the question is, how do we write the code so it works on both 2.34 and pre-2.34. It's no immediately obvious to me how to do that.

@fweimer-rh
Copy link
Contributor Author

If you build against glibc 2.34, the resulting binaries won't run on older glibc versions anyway, so you can just use a compile-time conditional, like:

#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 34)
// New code goes here.
#else
// Old code goes here.
#endif
#endif

Old binaries will continue to load (we are about to remove __pthread_mutex_lock, __pthread_mutex_trylock only for linking new programs), but I don't know to what extent your tool depends on glibc internals. glibc 2.34 no longer has a separate libpthread, and there have been quite some changes how things are linked together internally as a result. Some porting unrelated to the symbol changes I mentioned might be needed.

@khuey
Copy link
Collaborator

khuey commented Jul 6, 2021

Actually ignore my last comment, that was wrong.

@rocallahan
Copy link
Collaborator

Sounds like we should just add that conditional build stuff and then carry on building with an old distro for releases (and let me mention once again how annoying that requirement is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants