-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
let runc work with glibc lt 2.32 in go 1.22.x
Signed-off-by: lifubang <[email protected]>
- Loading branch information
Showing
1 changed file
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
//go:build go1.22 | ||
//go:build go1.22 && !go1.23 | ||
|
||
package nsenter | ||
|
||
/* | ||
// We know for sure that glibc has issues with pthread_self() when called from | ||
// Go after nsenter has run. This is likely a more general problem with how we | ||
// ignore the rules in signal-safety(7), and so it's possible musl will also | ||
// have issues, but as this is just a hotfix let's only block glibc builds. | ||
// In glibc versions older than 2.32 (before commit 4721f95058), | ||
// pthread_getattr_np does not always initialize the `attr` argument, | ||
// and when it fails, it results in a NULL pointer dereference in | ||
// pthread_attr_destroy down the road. This has been fixed in go 1.22.4. | ||
// We hack this to let runc can work with glibc < 2.32 in go 1.22.x, | ||
// once runc doesn't support 1.22, we can remove this hack. | ||
#include <features.h> | ||
#ifdef __GLIBC__ | ||
# error "runc does not currently work properly with Go >=1.22. See <https://github.com/opencontainers/runc/issues/4233>." | ||
#if __GLIBC__ && !__GLIBC_PREREQ(2, 32) | ||
#include <pthread.h> | ||
#cgo LDFLAGS: -Wl,--wrap=pthread_getattr_np | ||
int __real_pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr); | ||
int __wrap_pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) { | ||
pthread_attr_init(__attr); | ||
return __real_pthread_getattr_np(__th, __attr); | ||
} | ||
#endif | ||
*/ | ||
import "C" |