Skip to content

Infinite recursion tests triggering a segfault #62275

Closed

Description

@brettcannon
BPO 18075
Nosy @brettcannon, @ronaldoussoren, @vstinner, @larryhastings, @ned-deily, @miss-islington
PRs
  • bpo-34602: Avoid failures setting macOS stack resource limit #13011
  • [3.7] bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011) #13013
  • [3.6] bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011) #13014
  • bpo-34602: Avoid failures setting macOS stack resource limit #14546
  • [3.8] bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) #14547
  • [3.7] bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) #14548
  • [3.6] bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) #14549
  • Files
  • issue-18075-osx-stacksize.txt
  • issue-18075-osx-stacksize-update.txt
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ronaldoussoren'
    closed_at = <Date 2013-05-30.19:31:46.106>
    created_at = <Date 2013-05-28.01:02:08.341>
    labels = ['interpreter-core', 'type-crash', 'release-blocker']
    title = 'Infinite recursion tests triggering a segfault'
    updated_at = <Date 2019-07-02.22:34:03.946>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2019-07-02.22:34:03.946>
    actor = 'ned.deily'
    assignee = 'ronaldoussoren'
    closed = True
    closed_date = <Date 2013-05-30.19:31:46.106>
    closer = 'lukasz.langa'
    components = ['Interpreter Core']
    creation = <Date 2013-05-28.01:02:08.341>
    creator = 'brett.cannon'
    dependencies = []
    files = ['30397', '30399']
    hgrepos = []
    issue_num = 18075
    keywords = []
    message_count = 18.0
    messages = ['190162', '190192', '190200', '190205', '190206', '190354', '190355', '190356', '190358', '190378', '341111', '341113', '341117', '347112', '347114', '347116', '347118', '347166']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'ronaldoussoren', 'vstinner', 'larry', 'ned.deily', 'python-dev', 'miss-islington']
    pr_nums = ['13011', '13013', '13014', '14546', '14547', '14548', '14549']
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue18075'
    versions = ['Python 3.4']

    Activity

    1. brettcannon commented on May 28, 2013

      @brettcannon
      MemberAuthor

      If you run any test that has infinite recursion (test_json test_exceptions test_sys test_runpy) it will segfault with a fresh checkout under OS X 10.8.3 using Clang. Not sure how widespread this is.

      I did check that I am using a clean checkout of the default branch.

    2. ronaldoussoren commented on May 28, 2013

      @ronaldoussoren
      Contributor

      I can confirm the problem. It appears to be a stack overflow, when I increase the stack size of the main thead (by adding "-Wl,-stack_size,2faf000" to the link command for BUILDPYTHON) the crash in test_json goes away.

      Appearently the default maximum stack size isn't large enough for the default value of the recursion limit.

      An easy workaround (fix?) would be to add -Wl,-stack_size,VALUE to the link flags on OSX, for some sane value of VALUE. The value is the maximum size of the stack of the main thread and doesn't affect process size unless a process actually uses more stack space. It does affect the available free address space, and hence the maximum stack size shouldn't be increased too far (especially for 32-bit builds)

    3. ronaldoussoren commented on May 28, 2013

      @ronaldoussoren
      Contributor

      The attached patch fixes the problem on OSX by increasing the maximum stack size of the main thread from 8M (the default) to 16M.

      NOTE: The -Wl,-stack_size,... option cannot be added to LDFLAGS, ld errors out when that option is used when linking a shared library (such as the extensions or libpython.dylib)

    4. ronaldoussoren commented on May 28, 2013

      @ronaldoussoren
      Contributor

      The update fixes the name error mention in rietveld.

    5. brettcannon commented on May 28, 2013

      @brettcannon
      MemberAuthor

      LGTM

    6. vstinner commented on May 30, 2013

      @vstinner
      Member

      Appearently the default maximum stack size isn't large enough for the default value of the recursion limit.

      Why not changing the recursion limit instead of the size of the stack?

    7. ronaldoussoren commented on May 30, 2013

      @ronaldoussoren
      Contributor

      I'd prefer to keep the default recursion limit the same as on Linux, changing the recursion limit on OSX would just introduce an unnecessary difference between the two platforms.

      The patch changes the maximum stack size from 8 to 16 MByte, neither of which is huge and shouldn't cause other problems.

      I'd also like to increase the default stack size for newly created threads (see bpo-18049) and will update that patch to create a 16 MByte stack as well.

    8. vstinner commented on May 30, 2013

      @vstinner
      Member

      The patch changes the maximum stack size from 8 to 16 MByte, neither of which is huge and shouldn't cause other problems.

      On Mac OS X: Is the memory allocated at Python startup, or on demand,
      as the stack grows? If I am correct, the physical memory is allocated
      on demand on Linux.

      2013/5/30 Ronald Oussoren <report@bugs.python.org>:

      Ronald Oussoren added the comment:

      I'd prefer to keep the default recursion limit the same as on Linux, changing the recursion limit on OSX would just introduce an unnecessary difference between the two platforms.

      The patch changes the maximum stack size from 8 to 16 MByte, neither of which is huge and shouldn't cause other problems.

      I'd also like to increase the default stack size for newly created threads (see bpo-18049) and will update that patch to create a 16 MByte stack as well.

      ----------


      Python tracker <report@bugs.python.org>
      <http://bugs.python.org/issue18075\>


    9. ronaldoussoren commented on May 30, 2013

      @ronaldoussoren
      Contributor

      On 30 May, 2013, at 14:50, STINNER Victor <report@bugs.python.org> wrote:

      STINNER Victor added the comment:

      > The patch changes the maximum stack size from 8 to 16 MByte, neither of which is huge and shouldn't cause other problems.

      On Mac OS X: Is the memory allocated at Python startup, or on demand,
      as the stack grows? If I am correct, the physical memory is allocated
      on demand on Linux.

      Memory for the stack is allocated on demand, the parameter sets the maximum size that the stack can grow to. See also man ld(1).

      Ronald

    10. python-dev commented on May 30, 2013

      python-devmannequin
      Mannequin

      New changeset b07ad4b5e349 by Łukasz Langa in branch 'default':
      Fixed bpo-18075 - Infinite recursion tests triggering a segfault on Mac OS X
      http://hg.python.org/cpython/rev/b07ad4b5e349

    11. ned-deily commented on Apr 29, 2019

      @ned-deily
      Member

      New changeset 883dfc6 by Ned Deily in branch 'master':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011)
      883dfc6

    12. miss-islington commented on Apr 29, 2019

      @miss-islington
      Contributor

      New changeset 52a5b71 by Miss Islington (bot) in branch '3.7':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011)
      52a5b71

    13. ned-deily commented on Apr 29, 2019

      @ned-deily
      Member

      New changeset fbe2a13 by Ned Deily (Miss Islington (bot)) in branch '3.6':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011) (GH-13014)
      fbe2a13

    14. ned-deily commented on Jul 2, 2019

      @ned-deily
      Member

      New changeset 5bbbc73 by Ned Deily in branch 'master':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
      5bbbc73

    15. miss-islington commented on Jul 2, 2019

      @miss-islington
      Contributor

      New changeset bd92b94 by Miss Islington (bot) in branch '3.8':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
      bd92b94

    16. miss-islington commented on Jul 2, 2019

      @miss-islington
      Contributor

      New changeset bf82cd3 by Miss Islington (bot) in branch '3.7':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
      bf82cd3

    17. ned-deily commented on Jul 2, 2019

      @ned-deily
      Member

      New changeset 782854f by Ned Deily (Miss Islington (bot)) in branch '3.6':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546) (GH-14549)
      782854f

    18. ned-deily commented on Jul 2, 2019

      @ned-deily
      Member

      New changeset dcc0eb3 by Ned Deily (Miss Islington (bot)) in branch '3.7':
      bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
      dcc0eb3

    19. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions