Commit graph

132 commits

Author SHA1 Message Date
Miss Islington (bot)
8785eab342
[3.12] gh-116265: Remove obsolete sentence. (GH-116284) (#116331)
Remove sentence in Tools/c-analyzer/README referring to deleted
ignore-globals.txt.
(cherry picked from commit 88b5c665ee)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-03-04 22:20:44 +00:00
Miss Islington (bot)
14930acf5a
[3.12] gh-115399: Upgrade bundled libexpat to 2.6.0 (GH-115431) (#115469)
gh-115399: Upgrade bundled libexpat to 2.6.0 (GH-115431)
(cherry picked from commit 4b2d1786cc)

Co-authored-by: Seth Michael Larson <seth@python.org>
2024-02-14 14:14:34 -08:00
John Belmonte
09c98e4633
[3.12] gh-114563: C decimal falls back to pydecimal for unsupported format strings (GH-114879) (GH-115353)
Immediate merits:
* eliminate complex workarounds for 'z' format support
  (NOTE: mpdecimal recently added 'z' support, so this becomes
  efficient in the long term.)
* fix 'z' format memory leak
* fix 'z' format applied to 'F'
* fix missing '#' format support

Suggested and prototyped by Stefan Krah.

Fixes gh-114563, gh-91060

(cherry picked from commit 72340d15cd)

Co-authored-by: John Belmonte <john@neggie.net>
Co-authored-by: Stefan Krah <skrah@bytereef.org>
2024-02-12 23:31:12 +02:00
Erlend E. Aasland
6f5e360acd
[3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067)
(cherry picked from commit 09096a1647)
2024-02-06 11:20:16 +01:00
Miss Islington (bot)
8e37445044
[3.12] Remove imp_dummy_def from Tools/c-analyzer/cpython/ignored.tsv (gh-112122) (gh-112177)
It was removed in 3.12, no need to keep the ignore.
(cherry picked from commit 762eb58220)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-16 14:09:34 -07:00
Miss Islington (bot)
95fd4edc63
[3.12] gh-109098: Fuzz re module instead of internal sre (GH-109911) (#109932)
gh-109098: Fuzz re module instead of internal sre (GH-109911)

* gh-109098: Fuzz re module instead of internal sre
* Fix c-analyzer globals test failure
* Put globals exception in ignored.tsv
(cherry picked from commit a829356f86)

Co-authored-by: Ammar Askar <ammar@ammaraskar.com>
2023-10-02 17:39:07 +02:00
Miss Islington (bot)
98dd9d9725
[3.12] gh-91054: make code watcher tests resilient to other watchers (GH-107821) (#107835)
gh-91054: make code watcher tests resilient to other watchers (GH-107821)
(cherry picked from commit 2ec16fed14)

Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-08-11 16:13:14 +02:00
Charlie Zhao
99518bbbf4
[3.12] gh-106263: Fix segfault in signaldict_repr in _decimal module (#… (#107491)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>

(cherry picked from commit 3979150a0d)
2023-07-31 14:34:16 +02:00
Miss Islington (bot)
57ef065eb3
[3.12] gh-101524: Only Use Public C-API in the _xxsubinterpreters Module (gh-105258) (gh-107303)
The _xxsubinterpreters module was meant to only use public API.  Some internal C-API usage snuck in over the last few years (e.g. gh-28969).  This fixes that.
(cherry picked from commit e6373c0d8b)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-07-27 13:15:47 -06:00
Miss Islington (bot)
0373c2ccd5
[3.12] Fix c-analyzer for GCC: ignore LANG env var (GH-106173) (#106178)
Fix c-analyzer for GCC: ignore LANG env var (GH-106173)

The c-analyzer doesn't support GCC localized messages, so just unset
the LANG environment variable.
(cherry picked from commit 1f74b9e933)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-06-28 03:41:36 +00:00
Miss Islington (bot)
bc997b38b6
[3.12] gh-105699: Use a Thread-Local Variable for PKGCONTEXT (gh-105740) (gh-105765)
This fixes a race during import. The existing _PyRuntimeState.imports.pkgcontext is shared between interpreters, and occasionally this would cause a crash when multiple interpreters were importing extensions modules at the same time.  To solve this we add a thread-local variable for the value.  We also leave the existing state (and infrequent race) in place for platforms that do not support thread-local variables.
(cherry picked from commit b87d288275)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2023-06-14 01:34:26 +00:00
Eric Snow
33d3069c45
[3.12] gh-104812: Run Pending Calls in any Thread (gh-104813) (gh-105752)
For a while now, pending calls only run in the main thread (in the main interpreter).  This PR changes things to allow any thread run a pending call, unless the pending call was explicitly added for the main thread to run.
(cherry picked from commit 757b402)
2023-06-14 00:50:08 +00:00
Miss Islington (bot)
d57ee813eb
[3.12] gh-104614: Make Sure ob_type is Always Set Correctly by PyType_Ready() (gh-105122) (gh-105211)
When I added the relevant condition to type_ready_set_bases() in gh-103912, I had missed that the function also sets tp_base and ob_type (if necessary).  That led to problems for third-party static types.

We fix that here, by making those extra operations distinct and by adjusting the condition to be more specific.
(cherry picked from commit 1469393)

Co-authored-by: Eric Snow ericsnowcurrently@gmail.com
2023-06-01 23:06:38 +00:00
Miss Islington (bot)
25543aecfe
[3.12] gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174) (#105199)
gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174)

Upgrade builds to OpenSSL 1.1.1u.

This OpenSSL version addresses a pile if less-urgent CVEs since 1.1.1t.

The Mac/BuildScript/build-installer.py was already updated.

Also updates _ssl_data_111.h from OpenSSL 1.1.1u, _ssl_data_300.h from 3.0.9, and adds a new _ssl_data_31.h file from 3.1.1 along with the ssl.c code to use it.

Manual edits to the _ssl_data_300.h file prevent it from removing any existing definitions in case those exist in some peoples builds and were important (avoiding regressions during backporting).

backports of this prior to 3.12 will not include the openssl 3.1 header.
(cherry picked from commit ede89af605)

Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
2023-06-01 17:13:35 +00:00
gsallam
be0c106789
gh-103295: expose API for writing perf map files (#103546)
Co-authored-by: Aniket Panse <aniketpanse@fb.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2023-05-21 11:12:24 +01:00
Jelle Zijlstra
b9dce3aec4
gh-104549: Set __module__ on TypeAliasType (#104550) 2023-05-18 15:56:15 -07:00
Kumar Aditya
20e994c535
GH-103092: isolate pyexpat (#104506) 2023-05-16 20:03:01 +00:00
Erlend E. Aasland
186bf39f5c
gh-101819: Isolate _io (#101948)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-05-15 09:26:27 +00:00
Mark Shannon
45f5aa8fc7
GH-103082: Filter LINE events in VM, to simplify tool implementation. (GH-104387)
When monitoring LINE events, instrument all instructions that can have a predecessor on a different line.
Then check that the a new line has been hit in the instrumentation code.
This brings the behavior closer to that of 3.11, simplifying implementation and porting of tools.
2023-05-12 12:21:20 +01:00
Jonathan Protzenko
15665d896b
gh-99108: Replace SHA3 implementation HACL* version (#103597)
Replaces our built-in SHA3 implementation with a verified one from the HACL* project.

This implementation is used when OpenSSL does not provide SHA3 or is not present.

3.11 shiped with a very slow tiny sha3 implementation to get off of the <=3.10 reference implementation that wound up having serious bugs. This brings us back to a reasonably performing built-in implementation consistent with what we've just replaced our other guaranteed available standard hash algorithms with: code from the HACL* project.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-07 20:50:04 -07:00
Erlend E. Aasland
7a7eaff95c
gh-101819: Port _io.PyBytesIOBuffer_Type to heap type (#104264) 2023-05-07 14:01:27 +00:00
Erlend E. Aasland
cab1298a60
gh-101819: Adapt _io.PyWindowsConsoleIO_Type to heap type (#104197) 2023-05-07 11:23:11 +02:00
Erlend E. Aasland
3952379655
gh-101819: Port _io.PyIncrementalNewlineDecoder_Type to heap type (#104249) 2023-05-07 11:20:34 +02:00
Tian Gao
b979741731
gh-103533: Use PEP 669 APIs for cprofile (GH-103534) 2023-05-05 18:38:47 +01:00
Jelle Zijlstra
04f6733275
gh-102500: Implement PEP 688 (#102521)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-05-04 07:59:46 -07:00
Barry Warsaw
e1f14643dc
gh-98040: Remove just the imp module (#98573) 2023-04-28 16:17:58 -07:00
Erlend E. Aasland
8a0c7f1e40
gh-103583: Isolate CJK codec modules (#103869) 2023-04-27 15:02:43 +02:00
Erlend E. Aasland
e9c777208f
gh-103092: Isolate _ctypes, part 1 (#103893)
Establish global state and port the following types to heap types:

- DictRemover_Type
- PyCArg_Type
- PyCThunk_Type
- PyCField_Type
- StructParam_Type
2023-04-27 14:57:54 +02:00
Eric Snow
df3173d28e
gh-101659: Isolate "obmalloc" State to Each Interpreter (gh-101660)
This is strictly about moving the "obmalloc" runtime state from
`_PyRuntimeState` to `PyInterpreterState`.  Doing so improves isolation
between interpreters, specifically most of the memory (incl. objects)
allocated for each interpreter's use.  This is important for a
per-interpreter GIL, but such isolation is valuable even without it.

FWIW, a per-interpreter obmalloc is the proverbial
canary-in-the-coalmine when it comes to the isolation of objects between
interpreters.  Any object that leaks (unintentionally) to another
interpreter is highly likely to cause a crash (on debug builds at
least).  That's a useful thing to know, relative to interpreter
isolation.
2023-04-24 17:23:57 -06:00
Erlend E. Aasland
217911ede5
gh-103583: Add codecs and maps to _codecs_* module state (#103540) 2023-04-17 02:41:25 +02:00
Nikita Sobolev
7f3c106503
gh-103326: Remove Python/importlib.h (GH-103331)
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-04-12 11:27:14 -07:00
Erlend E. Aasland
52f96d3ea3
gh-103092: Isolate _collections (#103093)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-12 18:21:28 +05:30
Mark Shannon
411b169281
GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython (GH-103083)
* The majority of the monitoring code is in instrumentation.c

* The new instrumentation bytecodes are in bytecodes.c

* legacy_tracing.c adapts the new API to the old sys.setrace and sys.setprofile APIs
2023-04-12 12:04:55 +01:00
Nikita Sobolev
40db5c65b7
gh-103334: Ignore Tools/c-analyzer/cpython/_parser.py from patchcheck (GH-103335)
I've also added a small comment to `Tools/c-analyzer/cpython/_parser.py` to trigger the `patchcheck` CI. It must pass now.

Automerge-Triggered-By: GH:ericsnowcurrently
2023-04-10 07:58:48 -07:00
Erlend E. Aasland
f329a8bc1e
gh-103092: Isolate socket module (#103094) 2023-04-09 06:33:52 +05:30
Erlend E. Aasland
c00dcf0e38
gh-103092: Isolate _pickle module (#102982)
Co-authored-by: Mohamed Koubaa <koubaa.m@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-04 15:38:54 +05:30
Eric Snow
e647dbaded
gh-90110: Bring the whitelists up to date. (gh-103114)
https://github.com/python/cpython/issues/90110
2023-03-29 16:08:40 -06:00
Brandt Bucher
0444ae2487
GH-100982: Break up COMPARE_AND_BRANCH (GH-102801) 2023-03-23 15:25:09 -07:00
Nikita Sobolev
1ca315538f
gh-102033: Fix syntax error in Tools/c-analyzer (GH-102066)
The easiest way to format strings with `{}` meaningful chars is via `%`.
2023-03-22 07:59:32 -07:00
Eric Snow
ad77d16a62
gh-102304: Move _Py_RefTotal to _PyRuntimeState (gh-102543)
The essentially eliminates the global variable, with the associated benefits. This is also a precursor to isolating this bit of state to PyInterpreterState.

Folks that currently read _Py_RefTotal directly would have to start using _Py_GetGlobalRefTotal() instead.

https://github.com/python/cpython/issues/102304
2023-03-20 10:03:04 -06:00
Eric Snow
84e20c689a
gh-102737: Un-ignore ceval.c in the CI globals check (gh-102745)
The tool now allows user-added #LINE preprocessor directives.

https://github.com/python/cpython/issues/102737
2023-03-16 09:26:42 -06:00
Alex Waygood
215007b576
Exclude ceval.c from the C-analyzer tool (#102735)
The "check if generated files are up to date" CI check appears to be currently failing on all PRs (but not on pushes to main) 

See, for example:
- https://github.com/python/cpython/pull/94468
- https://github.com/python/cpython/pull/94468
- https://github.com/python/cpython/pull/102731

This appears to be because the C-analyzer tool doesn't like the `#line` directives introduced in 70185de1ab. I'm advised by the message printed to the terminal in 7768216988 (step):14:84 that this is the appropriate short-term fix!
2023-03-15 18:19:07 +00:00
Eric Snow
1ff81c0cb6
gh-81057: Add a CI Check for New Unsupported C Global Variables (gh-102506)
This will keep us from adding new unsupported (i.e. non-const) C global variables, which would break interpreter isolation.

FYI, historically it is very uncommon for new global variables to get added. Furthermore, it is rare for new code to break the c-analyzer. So the check should almost always pass unnoticed.

Note that I've removed test_check_c_globals. A test wasn't a great fit conceptually and was super slow on debug builds. A CI check is a better fit.

This also resolves gh-100237.

https://github.com/python/cpython/issues/81057
2023-03-14 10:05:54 -06:00
Eric Snow
ca066bdbed
gh-81057: Vendor a Subset of distutils for the c-analyzer Tool (gh-102505)
distutils was removed in November. However, the c-analyzer relies on it. To solve that here, we vendor the parts the tool needs so it can be run against 3.12+. (Also see gh-92584.)

Note that we may end up removing this code later in favor of a solution in common with the peg_generator tool (which also relies on distutils).  At the least, the copy here makes sure the c-analyzer tool works on 3.12+ in the meantime.
2023-03-09 09:50:33 -07:00
Eric Snow
8606697f49
gh-90110: Fix the c-analyzer Tool (#102483)
Some incompatible changes had gone in, and the "ignore" lists weren't properly undated. This change fixes that. It's necessary prior to enabling test_check_c_globals, which I hope to do soon.

Note that this does include moving last_resort_memory_error to PyInterpreterState.

https://github.com/python/cpython/issues/90110
2023-03-06 19:40:09 -07:00
Erlend E. Aasland
c00faf7943
gh-101819: Adapt _io types to heap types, batch 1 (GH-101949)
Adapt StringIO, TextIOWrapper, FileIO, Buffered*, and BytesIO types.

Automerge-Triggered-By: GH:erlend-aasland
2023-02-20 05:46:20 -08:00
Erlend E. Aasland
c1ce0d178f
gh-99138: Isolate _zoneinfo (#99218)
* Convert zone info type to heap type and add it to module state
* Add global variables to module state
2023-02-15 22:58:48 +01:00
Erlend E. Aasland
826bf0e695
gh-101277: Finalise isolating itertools (GH-101305)
Add repeat, islice, chain, tee, teedataobject, and batched types to module state.

Automerge-Triggered-By: GH:erlend-aasland
2023-02-10 03:58:14 -08:00
Erlend E. Aasland
00d092caa8
GH-91375: Purge asyncio static variables from globals-to-fix list (#101288) 2023-01-24 20:37:27 +05:30
Erlend E. Aasland
13566a37c2
GH-92123: Move _elementtree heap types to module state (#101187) 2023-01-21 12:01:15 +01:00