Turn a NotEnoughInformation exception for the HEAP method into an XFAIL. The HEAP method is known to be flaky in some cases: - In Python 3.10 and earlier with the default glibc malloc, a PyThreadState should exist on the heap that points to the interpreter state.
(
method: StackMethod,
)
| 177 | |
| 178 | @contextlib.contextmanager |
| 179 | def xfail_on_expected_exceptions( |
| 180 | method: StackMethod, |
| 181 | ) -> Generator[None, None, None]: |
| 182 | """Turn a NotEnoughInformation exception for the HEAP method into an XFAIL. |
| 183 | |
| 184 | The HEAP method is known to be flaky in some cases: |
| 185 | |
| 186 | - In Python 3.10 and earlier with the default glibc malloc, |
| 187 | a PyThreadState should exist on the heap that points to the |
| 188 | interpreter state. |
| 189 | - For Python 3.11 and later, the PyThreadState for the main thread is |
| 190 | statically allocated, so we would find a useful PyThreadState on the |
| 191 | heap only for multithreaded programs. |
| 192 | - For musl libc, its "mallocng" malloc uses the brk heap only for |
| 193 | metadata, and always puts user data on anonymous mappings, so we'd |
| 194 | never find a useful PyThreadstate on the heap segment. |
| 195 | |
| 196 | We want to keep running tests for the HEAP method to ensure it doesn't |
| 197 | break in unexpected ways, but we'll just imperatively xfail if we see the |
| 198 | failure condition that we know can happen. |
| 199 | """ |
| 200 | try: |
| 201 | yield |
| 202 | except NotEnoughInformation: # pragma: no cover |
| 203 | if method == StackMethod.HEAP: |
| 204 | pytest.xfail("Could not find interpreter state on brk heap") |
| 205 | raise |
| 206 | |
| 207 | |
| 208 | def python_has_inlined_eval_frames(major: int, minor: int) -> bool: |
no outgoing calls