Commit e104c08
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 b4db948 commit e104c08
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 | | |
| |||
10798 | 10800 | | |
10799 | 10801 | | |
10800 | 10802 | | |
10801 | | - | |
10802 | | - | |
| 10803 | + | |
10803 | 10804 | | |
10804 | 10805 | | |
10805 | 10806 | | |
| |||
10815 | 10816 | | |
10816 | 10817 | | |
10817 | 10818 | | |
10818 | | - | |
| 10819 | + | |
10819 | 10820 | | |
10820 | 10821 | | |
10821 | 10822 | | |
| |||
10824 | 10825 | | |
10825 | 10826 | | |
10826 | 10827 | | |
10827 | | - | |
10828 | | - | |
| 10828 | + | |
10829 | 10829 | | |
10830 | 10830 | | |
10831 | 10831 | | |
| |||
10844 | 10844 | | |
10845 | 10845 | | |
10846 | 10846 | | |
10847 | | - | |
| 10847 | + | |
10848 | 10848 | | |
10849 | 10849 | | |
10850 | 10850 | | |
| |||
13044 | 13044 | | |
13045 | 13045 | | |
13046 | 13046 | | |
13047 | | - | |
| 13047 | + | |
13048 | 13048 | | |
13049 | 13049 | | |
13050 | 13050 | | |
| |||
13096 | 13096 | | |
13097 | 13097 | | |
13098 | 13098 | | |
13099 | | - | |
| 13099 | + | |
13100 | 13100 | | |
13101 | 13101 | | |
13102 | 13102 | | |
| |||
13106 | 13106 | | |
13107 | 13107 | | |
13108 | 13108 | | |
13109 | | - | |
| 13109 | + | |
13110 | 13110 | | |
13111 | 13111 | | |
13112 | 13112 | | |
| |||
15808 | 15808 | | |
15809 | 15809 | | |
15810 | 15810 | | |
15811 | | - | |
| 15811 | + | |
15812 | 15812 | | |
15813 | 15813 | | |
15814 | 15814 | | |
| |||
15824 | 15824 | | |
15825 | 15825 | | |
15826 | 15826 | | |
15827 | | - | |
| 15827 | + | |
15828 | 15828 | | |
15829 | 15829 | | |
15830 | 15830 | | |
| |||
18433 | 18433 | | |
18434 | 18434 | | |
18435 | 18435 | | |
18436 | | - | |
| 18436 | + | |
18437 | 18437 | | |
18438 | 18438 | | |
18439 | 18439 | | |
| |||
18481 | 18481 | | |
18482 | 18482 | | |
18483 | 18483 | | |
18484 | | - | |
| 18484 | + | |
18485 | 18485 | | |
18486 | 18486 | | |
18487 | 18487 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
792 | 792 | | |
793 | 793 | | |
794 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
0 commit comments