Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
e64647fe
Commit
e64647fe
authored
Mar 26, 2019
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unbounded memory usage in deep spawn trees. Fixes #1371.
parent
6ddbac56
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
CHANGES.rst
CHANGES.rst
+3
-0
src/gevent/_ffi/loop.py
src/gevent/_ffi/loop.py
+3
-2
src/gevent/greenlet.py
src/gevent/greenlet.py
+6
-1
No files found.
CHANGES.rst
View file @
e64647fe
...
@@ -40,6 +40,9 @@
...
@@ -40,6 +40,9 @@
- Python 2: Avoid a memory leak when an `io.BufferedWriter` is wrapped
- Python 2: Avoid a memory leak when an `io.BufferedWriter` is wrapped
around a socket. Reported by Damien Tournoud in :issue:`1318`.
around a socket. Reported by Damien Tournoud in :issue:`1318`.
- Avoid unbounded memory usage when creating very deep spawn trees.
Reported in :issue:`1371` by dmrlawson.
1.4.0 (2019-01-04)
1.4.0 (2019-01-04)
==================
==================
...
...
src/gevent/_ffi/loop.py
View file @
e64647fe
...
@@ -98,7 +98,7 @@ class AbstractCallbacks(object):
...
@@ -98,7 +98,7 @@ class AbstractCallbacks(object):
This function should never return 0, as that's the default value that
This function should never return 0, as that's the default value that
Python exceptions will produce.
Python exceptions will produce.
"""
"""
#
print
("Running callback", handle)
#
_dbg
("Running callback", handle)
orig_ffi_watcher
=
None
orig_ffi_watcher
=
None
try
:
try
:
# Even dereferencing the handle needs to be inside the try/except;
# Even dereferencing the handle needs to be inside the try/except;
...
@@ -116,6 +116,7 @@ class AbstractCallbacks(object):
...
@@ -116,6 +116,7 @@ class AbstractCallbacks(object):
the_watcher
=
self
.
from_handle
(
handle
)
the_watcher
=
self
.
from_handle
(
handle
)
orig_ffi_watcher
=
the_watcher
.
_watcher
orig_ffi_watcher
=
the_watcher
.
_watcher
args
=
the_watcher
.
args
args
=
the_watcher
.
args
#_dbg("Running callback", the_watcher, orig_ffi_watcher, args)
if
args
is
None
:
if
args
is
None
:
# Legacy behaviour from corecext: convert None into ()
# Legacy behaviour from corecext: convert None into ()
# See test__core_watcher.py
# See test__core_watcher.py
...
@@ -204,7 +205,7 @@ class AbstractCallbacks(object):
...
@@ -204,7 +205,7 @@ class AbstractCallbacks(object):
# at least for signals under libuv, which are delivered at very odd times.
# at least for signals under libuv, which are delivered at very odd times.
# Hopefully the event still shows up when we poll the next time.
# Hopefully the event still shows up when we poll the next time.
watcher
=
None
watcher
=
None
handle
=
tb
.
tb_frame
.
f_locals
[
'handle'
]
if
tb
is
not
None
else
None
handle
=
tb
.
tb_frame
.
f_locals
.
get
(
'handle'
)
if
tb
is
not
None
else
None
if
handle
:
# handle could be NULL
if
handle
:
# handle could be NULL
watcher
=
self
.
from_handle
(
handle
)
watcher
=
self
.
from_handle
(
handle
)
if
watcher
is
not
None
:
if
watcher
is
not
None
:
...
...
src/gevent/greenlet.py
View file @
e64647fe
...
@@ -256,7 +256,12 @@ class Greenlet(greenlet):
...
@@ -256,7 +256,12 @@ class Greenlet(greenlet):
spawner
.
spawn_tree_locals
=
self
.
spawn_tree_locals
spawner
.
spawn_tree_locals
=
self
.
spawn_tree_locals
self
.
_spawning_stack_frames
=
_extract_stack
(
self
.
spawning_stack_limit
)
self
.
_spawning_stack_frames
=
_extract_stack
(
self
.
spawning_stack_limit
)
self
.
_spawning_stack_frames
.
extend
(
getattr
(
spawner
,
'_spawning_stack_frames'
,
[]))
# Don't copy the spawning greenlet's
# '_spawning_stack_frames' into ours. That's somewhat
# confusing, and, if we're not careful, a deep spawn tree
# can lead to excessive memory usage (an infinite spawning
# tree could lead to unbounded memory usage without care
# --- see https://github.com/gevent/gevent/issues/1371)
else
:
else
:
# None is the default for all of these in Cython, but we
# None is the default for all of these in Cython, but we
# need to declare them for pure-Python mode.
# need to declare them for pure-Python mode.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment