Пример #1
0
def setrecursionlimit(space, new_limit):
    """setrecursionlimit() sets the maximum number of nested calls that
can occur before a RuntimeError is raised.  On PyPy the limit is
approximative and checked at a lower level.  The default 1000
reserves 768KB of stack space, which should suffice (on Linux,
depending on the compiler settings) for ~1400 calls.  Setting the
value to N reserves N/1000 times 768KB of stack space.

Note that there are other factors that also limit the stack size.
The operating system typically sets a maximum which can be changed
manually (e.g. with "ulimit" on Linux) for the main thread.  For other
threads you can configure the limit by calling "threading.stack_size()".
"""
    from rpython.rlib.rstack import _stack_set_length_fraction
    from rpython.rlib.rgc import increase_root_stack_depth
    if new_limit <= 0:
        raise oefmt(space.w_ValueError, "recursion limit must be positive")
    # Some programs use very large values to mean "don't check, I want to
    # use as much as possible and then segfault".  Add a silent upper bound
    # of 10**6 here, because huge values cause huge shadowstacks to be
    # allocated (or MemoryErrors).
    if new_limit > 1000000:
        new_limit = 1000000
    space.sys.recursionlimit = new_limit
    _stack_set_length_fraction(new_limit * 0.001)
    increase_root_stack_depth(int(new_limit * 0.001 * 163840))
Пример #2
0
def entry_point(argv):
    if we_are_translated():
        from rpython.rlib import rstack
        rstack._stack_set_length_fraction(50.0)
    else:
        import sys
        sys.setrecursionlimit(100000)

    (filename, ret, args, conf) = parse_options(argv, default_config)
    config = conf

    if config["ReadStatefile"] and filename is not None:
        do_come_up(filename)

    boot()

    if filename is None:
        print_help(argv, config)
        return ret # quit early.

    (result, timing) = run(config, filename, args)

    if config["WriteStatefile"]:
        do_settle(filename)

    if config["Print"]:
        print result
    if config["Verbose"]:
        CompoundShape.print_verbose()
    if config["Verbose"] or config["Stats"]:
        print_statistics(timing, filename)
    return 0
Пример #3
0
 def entry_point(argv):
     _stack_set_length_fraction(0.1)
     try:
         return f(1)
     except StackOverflow:
         glob.n = 0
     _stack_set_length_fraction(float(argv[1]))
     try:
         return f(1)
     except StackOverflow:
         print glob.n
         return 0
Пример #4
0
 def entry_point(argv):
     _stack_set_length_fraction(0.1)
     try:
         return f(1)
     except StackOverflow:
         glob.n = 0
     _stack_set_length_fraction(float(argv[1]))
     try:
         return f(1)
     except StackOverflow:
         print glob.n
         return 0
Пример #5
0
def setrecursionlimit(space, new_limit):
    """setrecursionlimit() sets the maximum number of nested calls that
can occur before a RuntimeError is raised.  On PyPy the limit is
approximative and checked at a lower level.  The default 1000
reserves 768KB of stack space, which should suffice (on Linux,
depending on the compiler settings) for ~1400 calls.  Setting the
value to N reserves N/1000 times 768KB of stack space.
"""
    from rpython.rlib.rstack import _stack_set_length_fraction
    if new_limit <= 0:
        raise oefmt(space.w_ValueError, "recursion limit must be positive")
    space.sys.recursionlimit = new_limit
    _stack_set_length_fraction(new_limit * 0.001)
Пример #6
0
def setrecursionlimit(space, new_limit):
    """setrecursionlimit() sets the maximum number of nested calls that
can occur before a RuntimeError is raised.  On PyPy the limit is
approximative and checked at a lower level.  The default 1000
reserves 768KB of stack space, which should suffice (on Linux,
depending on the compiler settings) for ~1400 calls.  Setting the
value to N reserves N/1000 times 768KB of stack space.
"""
    from rpython.rlib.rstack import _stack_set_length_fraction
    if new_limit <= 0:
        raise oefmt(space.w_ValueError, "recursion limit must be positive")
    space.sys.recursionlimit = new_limit
    _stack_set_length_fraction(new_limit * 0.001)
Пример #7
0
Файл: vm.py Проект: xen0n/pypy
def setrecursionlimit(space, new_limit):
    """setrecursionlimit() sets the maximum number of nested calls that
can occur before a RuntimeError is raised.  On PyPy the limit is
approximative and checked at a lower level.  The default 1000
reserves 768KB of stack space, which should suffice (on Linux,
depending on the compiler settings) for ~1400 calls.  Setting the
value to N reserves N/1000 times 768KB of stack space.

Note that there are other factors that also limit the stack size.
The operating system typically sets a maximum which can be changed
manually (e.g. with "ulimit" on Linux) for the main thread.  For other
threads you can configure the limit by calling "threading.stack_size()".
"""
    from rpython.rlib.rstack import _stack_set_length_fraction
    from rpython.rlib.rgc import increase_root_stack_depth
    if new_limit <= 0:
        raise oefmt(space.w_ValueError, "recursion limit must be positive")
    space.sys.recursionlimit = new_limit
    _stack_set_length_fraction(new_limit * 0.001)
    increase_root_stack_depth(int(new_limit * 0.001 * 163840))