Repository navigation
Infinite recursion tests triggering a segfault #62275
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
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']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)release-blockertype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
brettcannon commentedon May 28, 2013
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.
ronaldoussoren commentedon May 28, 2013
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)
ronaldoussoren commentedon May 28, 2013
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)
ronaldoussoren commentedon May 28, 2013
The update fixes the name error mention in rietveld.
brettcannon commentedon May 28, 2013
LGTM
vstinner commentedon May 30, 2013
Why not changing the recursion limit instead of the size of the stack?
ronaldoussoren commentedon May 30, 2013
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.
vstinner commentedon May 30, 2013
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>:
ronaldoussoren commentedon May 30, 2013
On 30 May, 2013, at 14:50, STINNER Victor <report@bugs.python.org> wrote:
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
python-dev commentedon May 30, 2013
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
ned-deily commentedon Apr 29, 2019
New changeset 883dfc6 by Ned Deily in branch 'master':
bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011)
883dfc6
miss-islington commentedon Apr 29, 2019
New changeset 52a5b71 by Miss Islington (bot) in branch '3.7':
bpo-34602: Avoid failures setting macOS stack resource limit (GH-13011)
52a5b71
ned-deily commentedon Apr 29, 2019
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
ned-deily commentedon Jul 2, 2019
New changeset 5bbbc73 by Ned Deily in branch 'master':
bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
5bbbc73
miss-islington commentedon Jul 2, 2019
New changeset bd92b94 by Miss Islington (bot) in branch '3.8':
bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
bd92b94
miss-islington commentedon Jul 2, 2019
New changeset bf82cd3 by Miss Islington (bot) in branch '3.7':
bpo-34602: Avoid failures setting macOS stack resource limit (GH-14546)
bf82cd3
ned-deily commentedon Jul 2, 2019
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
ned-deily commentedon Jul 2, 2019
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