GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement stack overflow protection for linux based on actual stack depth · Issue #130396 · python/cpython

Implement stack overflow protection for linux based on actual stack depth #130396

New issue
Copy link
New issue
Copy link
Closed
Closed
Implement stack overflow protection for linux based on actual stack depth#130396
Copy link
Labels
OS-linuxinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

Description

@markshannon
markshannon
opened on Feb 21, 2025
Issue body actions

Linux doesn't offer an API for determining the current stack bounds, at least not that I am aware of.

This means we will need to probe the stack using a SIGSEGV handler and longjmp/setjump.
It is somewhat ugly but should work.

Actually, it looks like pthread_get_stackaddr_np might work, and avoid all the complexity of the signal handler. In theory, it should work for MacOS as well.

Linked PRs

  • GH-130396: Use computed stack limits on linux #130398
  • GH-130396: Broaden definition of "optimized" for gdb tests #130550
  • GH-130396: Increase trashcan overhead #130552
  • GH-130396: Include stack margin for debug windows builds #130554
  • [3.13] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550) #130572
  • [3.12] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550) #130573
  • [3.11] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550) (GH-130573) #130593
  • gh-130396: Fix thread sanitizer crashes on stack overflow tests #130966
  • GH-130396: Work around for broken pthread_get_stackaddr_np on Emscripten #131088
  • gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers #135928
  • [3.14] gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (GH-135928) #136173
  • gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function #141951
  • gh-130396: Export _Py_ReachedRecursionLimitWithMargin() #142012

Activity

Next
  1. markshannon
    added a parent issue on Feb 21, 2025
    • Implement stack overflow protection for supported platforms #91079
  2. tomasr8
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    OS-linux
    on Feb 21, 2025
  3. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Feb 21, 2025
  4. markshannon
    added a commit that references this issue on Feb 25, 2025

    GH-130396: Use computed stack limits on linux (GH-130398)

    0142236
  5. encukou commented on Feb 25, 2025

    @encukou
    encukou
    on Feb 25, 2025
    Member
    More actions

    This broke two buildbots (both can be seen in the pre-merge run):

    • AMD64 Windows Server 2022 NoGIL (tier 1): test_trashcan_python_class1 loops with endless repetition of Exception ignored in audit hook: RecursionError: Stack overflow (used 11729 kB)
    • AMD64 Fedora Stable Clang 3.x (tier 2): several test_gdb failures.

    Do you have any leads on these issues?

  6. markshannon
    added 3 commits that reference this issue on Feb 25, 2025

    GH-130396: Include stack margin for debug windows builds (GH-130554)

    2dad1e0

    GH-130396: Increase trashcan overhead (GH-130552)

    263d56e

    GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550)

    129db32
  7. miss-islington
    added a commit that references this issue on Feb 26, 2025

    pythonGH-130396: Treat clang -Og as optimized for gdb tests (pythonGH…

    e85905c
  8. vstinner
    added 2 commits that reference this issue on Feb 26, 2025

    [3.13] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550…

    43a2a37

    [3.12] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550…

    c4aeb4c
  9. miss-islington
    added a commit that references this issue on Feb 26, 2025

    [3.12] pythonGH-130396: Treat clang -Og as optimized for gdb tests (p…

    40b2e6b
  10. pablogsal
    added a commit that references this issue on Feb 27, 2025

    [3.11] GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550…

    f1897d3
  11. colesbury commented on Feb 27, 2025

    @colesbury
    colesbury
    on Feb 27, 2025
    Contributor
    More actions

    I'm seeing SIGBUS in a compilation modes that use a lot of stack:

    export CC=clang-19
    ./configure -C --with-pydebug --with-thread-sanitizer --disable-gil
    make -j
    
    export TSAN_OPTIONS="suppressions=$(pwd)/Tools/tsan/suppressions_free_threading.txt handle_segv=0"
    ./python -m test test_dictviews -m test_deeply_nested_repr
    

    EDIT: The suppressions seems to be important for reproducing the crash.

  12. 12 remaining items

  13. vstinner
    added a commit that references this issue on Jul 1, 2025

    gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (#135928)

    28940e8
  14. miss-islington
    added a commit that references this issue on Jul 1, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    3059744
  15. vstinner
    added a commit that references this issue on Jul 1, 2025

    [3.14] gh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (GH…

    f152d60
  16. AndPuQing
    added a commit that references this issue on Jul 11, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    ba6bfaf
  17. Pranjal095
    added a commit that references this issue on Jul 12, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    0668154
  18. picnixz
    added a commit that references this issue on Jul 13, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    8d2ee3f
  19. taegyunkim
    added a commit that references this issue on Aug 4, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    04f5497
  20. Agent-Hellboy
    added a commit that references this issue on Aug 19, 2025

    pythongh-130396: Move PYOS_LOG2_STACK_MARGIN to internal headers (pyt…

    1238780
  21. vstinner
    added 4 commits that reference this issue on Nov 25, 2025

    pythongh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function

    28e4a39

    gh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function (#14…

    7fe1a18

    pythongh-130396: Export _Py_ReachedRecursionLimitWithMargin()

    de8663b

    gh-130396: Export _Py_ReachedRecursionLimitWithMargin() (#142012)

    9c4ff8a
  22. StanFromIreland
    added 2 commits that reference this issue on Dec 6, 2025

    pythongh-130396: Remove _Py_ReachedRecursionLimitWithMargin() function (

    1678fc6

    pythongh-130396: Export _Py_ReachedRecursionLimitWithMargin() (python…

    f84b3c1
  23. markshannon
    closed this as completedon Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-linuxinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.