Commit c3a2c4f
committed
gh-153400: 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.
Signed-off-by: Daan De Meyer <daan@amutable.com>1 parent 4f3be1b commit c3a2c4f
5 files changed
Lines changed: 171 additions & 22 deletions
File tree
- Misc/NEWS.d/next/Library
- Modules
- clinic
- Tools/c-analyzer/cpython
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
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 | | |
| |||
10776 | 10778 | | |
10777 | 10779 | | |
10778 | 10780 | | |
10779 | | - | |
10780 | | - | |
| 10781 | + | |
10781 | 10782 | | |
10782 | 10783 | | |
10783 | 10784 | | |
| |||
10793 | 10794 | | |
10794 | 10795 | | |
10795 | 10796 | | |
10796 | | - | |
| 10797 | + | |
10797 | 10798 | | |
10798 | 10799 | | |
10799 | 10800 | | |
| |||
10802 | 10803 | | |
10803 | 10804 | | |
10804 | 10805 | | |
10805 | | - | |
10806 | | - | |
| 10806 | + | |
10807 | 10807 | | |
10808 | 10808 | | |
10809 | 10809 | | |
| |||
10822 | 10822 | | |
10823 | 10823 | | |
10824 | 10824 | | |
10825 | | - | |
| 10825 | + | |
10826 | 10826 | | |
10827 | 10827 | | |
10828 | 10828 | | |
| |||
13021 | 13021 | | |
13022 | 13022 | | |
13023 | 13023 | | |
13024 | | - | |
| 13024 | + | |
13025 | 13025 | | |
13026 | 13026 | | |
13027 | 13027 | | |
| |||
13073 | 13073 | | |
13074 | 13074 | | |
13075 | 13075 | | |
13076 | | - | |
| 13076 | + | |
13077 | 13077 | | |
13078 | 13078 | | |
13079 | 13079 | | |
| |||
13083 | 13083 | | |
13084 | 13084 | | |
13085 | 13085 | | |
13086 | | - | |
| 13086 | + | |
13087 | 13087 | | |
13088 | 13088 | | |
13089 | 13089 | | |
| |||
15777 | 15777 | | |
15778 | 15778 | | |
15779 | 15779 | | |
15780 | | - | |
| 15780 | + | |
15781 | 15781 | | |
15782 | 15782 | | |
15783 | 15783 | | |
| |||
15793 | 15793 | | |
15794 | 15794 | | |
15795 | 15795 | | |
15796 | | - | |
| 15796 | + | |
15797 | 15797 | | |
15798 | 15798 | | |
15799 | 15799 | | |
| |||
18396 | 18396 | | |
18397 | 18397 | | |
18398 | 18398 | | |
18399 | | - | |
| 18399 | + | |
18400 | 18400 | | |
18401 | 18401 | | |
18402 | 18402 | | |
| |||
18444 | 18444 | | |
18445 | 18445 | | |
18446 | 18446 | | |
18447 | | - | |
| 18447 | + | |
18448 | 18448 | | |
18449 | 18449 | | |
18450 | 18450 | | |
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
0 commit comments