Commit graph

7518 commits

Author SHA1 Message Date
Batuhan Taskaya
a3480ec795
[3.11] gh-99103: Normalize specialized traceback anchors against the current line (#99423)
[3.11] gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)

Automerge-Triggered-By: GH:isidentical.
(cherry picked from commit 57be545959)

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
2022-11-21 22:16:12 +00:00
Miss Islington (bot)
9dda9020ab
gh-99578: Fix refleak in _imp.create_builtin() (GH-99642)
Fix a reference bug in _imp.create_builtin() after the creation of
the first sub-interpreter for modules "builtins" and "sys".
(cherry picked from commit cb2ef8b2ac)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-11-21 03:43:23 -08:00
Miss Islington (bot)
aa067868ec
[3.11] gh-99337: Fix compile errors with gcc 12 on macOS (GH-99470) (#99638)
gh-99337: Fix compile errors with gcc 12 on macOS (GH-99470)

Fix a number of compile errors with GCC-12 on macOS:

1. In pylifecycle.c the compile rejects _Pragma within a declaration
2. posixmodule.c was missing a number of ..._RUNTIME macros for non-clang on macOS
3. _ctypes assumed that __builtin_available is always present on macOS
(cherry picked from commit cdde29dde9)

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>

Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
2022-11-21 11:22:10 +01:00
Hood Chatham
a06fb519af
[3.11] GH-99460: Emscripten trampolines on optimized METH_O and METH_NOARGS code paths (gh-99461) (#99514)
Manual backport of GH-99461.
2022-11-16 08:09:34 -08:00
Miss Islington (bot)
f4cb8285ba
gh-87604: Avoid publishing list of active per-interpreter audit hooks via the gc module (GH-99373)
(cherry picked from commit 4e4b13e8f6)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-11-15 13:10:27 -08:00
Brandt Bucher
1119ee4f7e
[3.11] GH-99298: Don't perform jumps before error handling (GH-99343) 2022-11-11 11:30:21 +00:00
Miss Islington (bot)
f9a68be673
[3.11] GH-99257: Check the owner's type when specializing slots (GH-99324)
(cherry picked from commit 9d69284169)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-11-10 08:44:49 -08:00
Miss Islington (bot)
7c9c993945
GH-99205: Mark new interpreters and threads as non-static (GH-99268)
(cherry picked from commit 283ab0e1c0)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-11-09 14:19:15 -08:00
Miss Islington (bot)
41a9f49bc5
gh-98978: Fix Py_SetPythonHome(NULL) (GH-99066)
Fix use-after-free in Py_SetPythonHome(NULL), Py_SetProgramName(NULL)
and _Py_SetProgramFullPath(NULL) function calls.

Issue reported by Benedikt Reinartz.
(cherry picked from commit b07f546ea3)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-11-03 11:09:15 -07:00
Miss Islington (bot)
39e0627b77
[3.11] gh-98925: Lower marshal recursion depth for WASI (GH-98938) (GH-98979)
* gh-98925: Lower marshal recursion depth for WASI (GH-98938)

For wasmtime 2.0, the stack depth cost is 6% higher. This causes the default max `marshal` recursion depth to blow the stack.

As the default marshal depth is 2000 and Windows is set to 1000, split the difference and choose 1500 for WASI to be safe.
(cherry picked from commit 9711265182)

Co-authored-by: Brett Cannon <brett@python.org>
2022-11-01 16:18:55 -07:00
Miss Islington (bot)
57dd11038f
[3.11] gh-96853: Restore test coverage for Py_Initialize(Ex) (GH-98874)
* As most of `test_embed` now uses `Py_InitializeFromConfig`, add
  a specific test case to cover `Py_Initialize` (and `Py_InitializeEx`)
* Rename `_testembed` init helper to clarify the API used
* Add a `PyConfig_Clear` call in `Py_InitializeEx` to make
  the code more obviously correct (it already didn't leak as
  none of the dynamically allocated config fields were being
  populated, but it's clearer if the wrappers follow the
  documented API usage guidelines)
(cherry picked from commit 05e48865be)

Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
2022-10-31 09:15:12 +10:00
Brandt Bucher
0a67f82eb1
[3.11] GH-93354: Fix PRECALL's adaptive backoff (GH-98011) 2022-10-12 16:04:47 -07:00
Miss Islington (bot)
0a84b7aa4d
Add a warning message about PyOS_snprintf (GH-95993)
(cherry picked from commit c7b2204996)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
2022-10-07 13:26:46 -07:00
Miss Islington (bot)
89e9474327
[3.11] GH-97002: Prevent _PyInterpreterFrames from backing more than one PyFrameObject (GH-98002)
(cherry picked from commit 21a2d9ff55)
2022-10-06 17:36:39 -07:00
Christian Heimes
eecbeec083
[3.11] gh-96017: Fix some compiler warnings (GH-96018) (#96106)
- only define recreate_gil with ifdef HAVE_FORK.
(cherry picked from commit d9c1b746b5)

Co-authored-by: Christian Heimes <christian@python.org>
2022-10-05 15:05:27 -07:00
Miss Islington (bot)
015b49ac05
[3.11] GH-97779: Ensure that *all* frame objects are backed by "complete" frames (GH-97886)
(cherry picked from commit 0ff8fd6583)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-10-04 22:46:34 -07:00
Miss Islington (bot)
4591dae421
[3.11] GH-97752: Clear the previous member of newly-created generator/coroutine frames (GH-97812)
(cherry picked from commit 93fcc1f413)
2022-10-03 21:03:26 -07:00
Benjamin Peterson
4d4b1e6c0b
[3.11] Fix typos in bltinmodule.c. (GH-97789)
(cherry picked from commit 873a2f2527)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-03 13:10:14 -07:00
Miss Islington (bot)
a4ff0eaaf0
gh-96848: Fix -X int_max_str_digits option parsing (GH-96988)
Fix command line parsing: reject "-X int_max_str_digits" option with
no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
variable is set to a valid limit.
(cherry picked from commit 41351662bc)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-09-26 08:43:26 -07:00
Miss Islington (bot)
6a646dd1ff
GH-96975: Skip incomplete frames in PyEval_GetFrame (GH-97018)
(cherry picked from commit 8fd2c3b75b)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-22 10:17:53 -07:00
Brandt Bucher
fb87aaafba
Remove a stray DISPATCH() (GH-97004) 2022-09-22 09:18:37 -07:00
Brandt Bucher
0e61d2b557
[3.11] GH-95921: Fix positions for some chained comparisons (GH-96968) (GH-96973)
(cherry picked from commit dfc73b5724)

Automerge-Triggered-By: GH:brandtbucher
2022-09-20 14:56:38 -07:00
Miss Islington (bot)
32d80decbf
GH-96864: Check for error between line and opcode events (GH-96880)
(cherry picked from commit c10e33ac11)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-09-20 10:49:01 -07:00
Victor Stinner
6ff54716f1
gh-96387: take_gil() resets drop request before exit (#96869) (#96941)
At Python exit, sometimes a thread holding the GIL can wait forever
for a thread (usually a daemon thread) which requested to drop the
GIL, whereas the thread already exited. To fix the race condition,
the thread which requested the GIL drop now resets its request before
exiting.

take_gil() now calls RESET_GIL_DROP_REQUEST() before
PyThread_exit_thread() if it called SET_GIL_DROP_REQUEST to fix a
race condition with drop_gil().

Issue discovered and analyzed by Mingliang ZHAO.

(cherry picked from commit 04f4977f50)
2022-09-20 02:12:09 +02:00
Miss Islington (bot)
c4cf745c72
GH-96754: Check whether the interpreter frame is complete before creating frame object. (GH-96776) (#96787)
(cherry picked from commit 12c5f328d2)

Co-authored-by: Mark Shannon <mark@hotpy.org>

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-09-13 11:56:27 +01:00
Christian Heimes
4958820032
[3.11] gh-95853: Add script to automate WASM build (GH-95828, GH-95985, GH-96045, GH-96389, GH-96744) (GH-96749)
Automate WASM build with a new Python script. The script provides
several build profiles with configure flags for Emscripten flavors
and WASI. The script can detect and use Emscripten SDK and WASI SDK from
default locations or env vars.

``configure`` now detects Node arguments and creates HOSTRUNNER
arguments for Node 16. It also sets correct arguments for
``wasm64-emscripten``.
2022-09-13 12:06:39 +02:00
Miss Islington (bot)
7033dc8adc
GH-96678: Fix undefined behavior in ceval.c (GH-96708)
(cherry picked from commit 50a70a083d)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-09-10 06:58:45 -07:00
Miss Islington (bot)
c563b89261
Fix possible NULL pointer dereference in _PyThread_CurrentFrames (GH-96584)
(cherry picked from commit 88a7f661ca)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-09-10 04:12:46 -07:00
Mark Shannon
5586da65e2
[3.11] GH-96636: Remove all uses of NOTRACE_DISPATCH (GH-96643) (#96688)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
(cherry picked from commit aa3b4cf779)
2022-09-09 09:24:44 -07:00
Mark Shannon
e72f469e85
[3.11] GH-96569: Avoid undefined behavior (#96616)
Co-authored-by: Michael Droettboom <mdboom@gmail.com>
2022-09-08 12:00:04 +01:00
Miss Islington (bot)
a389fdb095
GH-96572: fix use after free in trace refs build mode (GH-96618)
(cherry picked from commit 67444902a0)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-09-06 11:28:18 -07:00
Gregory P. Smith
f8b71da9aa
[3.11] gh-95778: CVE-2020-10735: Prevent DoS by very large int() (#96500)
Integer to and from text conversions via CPython's bignum `int` type is not safe against denial of service attacks due to malicious input. Very large input strings with hundred thousands of digits can consume several CPU seconds.

This PR comes fresh from a pile of work done in our private PSRT security response team repo.

This backports https://github.com/python/cpython/pull/96499 aka 511ca94520

Signed-off-by: Christian Heimes [Red Hat] <christian@python.org>
Tons-of-polishing-up-by: Gregory P. Smith [Google] <greg@krypto.org>
Reviews via the private PSRT repo via many others (see the NEWS entry in the PR).

<!-- gh-issue-number: gh-95778 -->
* Issue: gh-95778
<!-- /gh-issue-number -->

I wrote up [a one pager for the release managers](https://docs.google.com/document/d/1KjuF_aXlzPUxTK4BMgezGJ2Pn7uevfX7g0_mvgHlL7Y/edit#).
2022-09-02 09:48:57 -07:00
Miss Islington (bot)
27f390bc30
gh-96125: Fix sys.thread_info.name on pthread platforms (GH-96126) (#96128)
Automerge-Triggered-By: GH:tiran
(cherry picked from commit 822955c166)

Co-authored-by: Christian Heimes <christian@python.org>

Co-authored-by: Christian Heimes <christian@python.org>
2022-08-21 17:37:15 +01:00
Miss Islington (bot)
1fa9644c23
GH-96071: fix deadlock in PyGILState_Ensure (GH-96124) (#96129)
Alternative of GH-96107
(cherry picked from commit e0d54a4a79)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-08-19 22:11:31 +01:00
Miss Islington (bot)
6fc90c1183
GH-95818: Skip incomplete frames in PyThreadState_GetFrame (GH-95886) (#95890)
(cherry picked from commit 1b46d118e6)

Co-authored-by: Mark Shannon <mark@hotpy.org>

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-08-12 19:40:49 +01:00
Christian Heimes
e62a0dfab2
[3.11] gh-95174: Add pthread stubs for WASI (GH-95234) (#95503)
Co-authored-by: Brett Cannon <brett@python.org>.
(cherry picked from commit 0fe645d6fd)

Co-authored-by: Christian Heimes <christian@python.org>
2022-08-01 15:37:45 +01:00
Miss Islington (bot)
147a9a8be7
bpo-45445: Revert "bpo-45445: Fail if an invalid X-option is provided in the command line (GH-28823)" (GH-94745)
(cherry picked from commit aa37ffda29)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-07-31 08:58:02 -07:00
Christian Heimes
db13c0c1b8
[3.11] gh-95174: Handle missing dup() and constants in WASI (GH-95229) (GH-95272)
Co-authored-by: Christian Heimes <christian@python.org>
2022-07-31 16:39:41 +01:00
Miss Islington (bot)
00566a8124
GH-90081: Run python tracers at full speed (GH-95328) (#95363)
(cherry picked from commit b8b2990fb3)

Co-authored-by: Mark Shannon <mark@hotpy.org>

Co-authored-by: Mark Shannon <mark@hotpy.org>
2022-07-29 09:43:52 +01:00
Serhiy Storchaka
33efd7f7a3
[3.11] gh-94938: Fix errror detection of unexpected keyword arguments (GH-94999) (GH-95353)
When keyword argument name is an instance of a str subclass with
overloaded methods __eq__ and __hash__, the former code could not find
the name of an extraneous keyword argument to report an error, and
_PyArg_UnpackKeywords() returned success without setting the
corresponding cell in the linearized arguments array. But since the number
of expected initialized cells is determined as the total number of passed
arguments, this lead to reading NULL as a keyword parameter value, that
caused SystemError or crash or other undesired behavior.
(cherry picked from commit ebad53a4dc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-07-28 09:51:45 +03:00
Miss Islington (bot)
86eb500068
[3.11] gh-95185: Check recursion depth in the AST constructor (GH-95186) (GH-95208)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 0047447294)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-07-26 12:19:22 +02:00
Mark Shannon
e5ff5ec3ff
[3.11] GH-94739: Backport GH-94958 to 3.11 (#94965) 2022-07-25 12:11:06 +01:00
Brandt Bucher
064462a719
[3.11] GH-94036: Fix more attribute location quirks (GH-95028) (GH-95156)
(cherry picked from commit 900bfc53cb)
2022-07-22 17:31:06 -07:00
Brandt Bucher
5a48ab01e9
[3.11] GH-95113: Don't use EXTENDED_ARG_QUICK in unquickened code (GH-95121) (GH-95143)
(cherry picked from commit e402b26b7f)
2022-07-22 11:56:10 -07:00
Brandt Bucher
e2fce3a8e7
[3.11] GH-91409: Don't overwrite valid locations with NOP locations (GH-95067) (GH-95068)
(cherry picked from commit 742d4614e1)
2022-07-20 15:01:42 -07:00
Miss Islington (bot)
16cb8ca52e
GH-94851: fix immortal objects refcounting in compiler (gh-95040)
(cherry picked from commit 7476154886)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-07-20 03:42:05 -07:00
Miss Islington (bot)
bb8e20a329
gh-91256: Ensure help text has the program name even before getpath is called (GH-94929)
(cherry picked from commit 49aeff49d7)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-07-19 12:03:15 -07:00
Brandt Bucher
eda2f90094
[3.11] GH-94822: Don't specialize when metaclasses are involved (GH-94892) (GH-94980)
(cherry picked from commit daf68ba92f)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
2022-07-18 11:55:07 -07:00
Miss Islington (bot)
ec6ed6681d
gh-94930: skipitem() in getargs.c should return non-NULL on error (GH-94931)
(cherry picked from commit 067f0da335)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-07-18 08:41:22 -07:00
Miss Islington (bot)
1c63734217
gh-91348: Restore frame argument to sys._getframe audit event (GH-94928)
(cherry picked from commit 044a593cbb)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-07-17 08:49:57 -07:00