Commit 9a8baaa
committed
Resolve newer libc/syscall wrappers at runtime on Linux
os functions like copy_file_range() are gated on a configure-time
AC_CHECK_FUNCS probe and compiled out when the build libc lacks the
symbol. A redistributable built against an old glibc (the
python-build-standalone builds target glibc 2.17) therefore never
exposes them, even when run on a newer glibc or a capable kernel.
Add Modules/posixshims.h, which on Linux always exposes _Py_<func>(),
resolves the libc symbol once at load time via dlsym(RTLD_DEFAULT) from a
constructor, and falls back to the raw syscall when the running libc
lacks the wrapper. Resolving in a constructor keeps dlsym(), which is not
async-signal-safe, out of signal handlers and the fork()/exec() window.
Off Linux the classic build-time HAVE_* direct calls are kept.
Limit the shims to wrappers newer than the glibc 2.17 baseline, since
anything at or below it is always present in the build libc:
copy_file_range (glibc 2.27)
memfd_create (glibc 2.27)
pidfd_open (glibc 2.36)
pidfd_getfd (glibc 2.36)
pidfd_open() and pidfd_getfd() previously issued raw syscalls
unconditionally; they now prefer the glibc wrapper when present.1 parent f3fd9dc commit 9a8baaa
3 files changed
Lines changed: 170 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| |||
10773 | 10775 | | |
10774 | 10776 | | |
10775 | 10777 | | |
10776 | | - | |
10777 | | - | |
| 10778 | + | |
10778 | 10779 | | |
10779 | 10780 | | |
10780 | 10781 | | |
| |||
10790 | 10791 | | |
10791 | 10792 | | |
10792 | 10793 | | |
10793 | | - | |
| 10794 | + | |
10794 | 10795 | | |
10795 | 10796 | | |
10796 | 10797 | | |
| |||
10799 | 10800 | | |
10800 | 10801 | | |
10801 | 10802 | | |
10802 | | - | |
10803 | | - | |
| 10803 | + | |
10804 | 10804 | | |
10805 | 10805 | | |
10806 | 10806 | | |
| |||
10819 | 10819 | | |
10820 | 10820 | | |
10821 | 10821 | | |
10822 | | - | |
| 10822 | + | |
10823 | 10823 | | |
10824 | 10824 | | |
10825 | 10825 | | |
| |||
13018 | 13018 | | |
13019 | 13019 | | |
13020 | 13020 | | |
13021 | | - | |
| 13021 | + | |
13022 | 13022 | | |
13023 | 13023 | | |
13024 | 13024 | | |
| |||
13070 | 13070 | | |
13071 | 13071 | | |
13072 | 13072 | | |
13073 | | - | |
| 13073 | + | |
13074 | 13074 | | |
13075 | 13075 | | |
13076 | 13076 | | |
| |||
13080 | 13080 | | |
13081 | 13081 | | |
13082 | 13082 | | |
13083 | | - | |
| 13083 | + | |
13084 | 13084 | | |
13085 | 13085 | | |
13086 | 13086 | | |
| |||
15774 | 15774 | | |
15775 | 15775 | | |
15776 | 15776 | | |
15777 | | - | |
| 15777 | + | |
15778 | 15778 | | |
15779 | 15779 | | |
15780 | 15780 | | |
| |||
15790 | 15790 | | |
15791 | 15791 | | |
15792 | 15792 | | |
15793 | | - | |
| 15793 | + | |
15794 | 15794 | | |
15795 | 15795 | | |
15796 | 15796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
0 commit comments