Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
682107cf
Commit
682107cf
authored
Sep 09, 2019
by
Zackery Spytz
Committed by
T. Wouters
Sep 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36279: Ensure os.wait3() rusage is initialized (GH-15111)
Co-Authored-By:
David Wilson
<
dw@botanicus.net
>
parent
d91d4de3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
Lib/test/test_wait3.py
Lib/test/test_wait3.py
+18
-0
Misc/NEWS.d/next/Core and Builtins/2019-08-04-12-24-18.bpo-36279.8Zy7jZ.rst
...ore and Builtins/2019-08-04-12-24-18.bpo-36279.8Zy7jZ.rst
+1
-0
Modules/posixmodule.c
Modules/posixmodule.c
+6
-0
No files found.
Lib/test/test_wait3.py
View file @
682107cf
...
...
@@ -2,6 +2,8 @@
"""
import
os
import
subprocess
import
sys
import
time
import
unittest
from
test.fork_wait
import
ForkWait
...
...
@@ -31,6 +33,22 @@ class Wait3Test(ForkWait):
self
.
assertEqual
(
status
,
0
,
"cause = %d, exit = %d"
%
(
status
&
0xff
,
status
>>
8
))
self
.
assertTrue
(
rusage
)
def
test_wait3_rusage_initialized
(
self
):
# Ensure a successful wait3() call where no child was ready to report
# its exit status does not return uninitialized memory in the rusage
# structure. See bpo-36279.
args
=
[
sys
.
executable
,
'-c'
,
'import sys; sys.stdin.read()'
]
proc
=
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
)
try
:
pid
,
status
,
rusage
=
os
.
wait3
(
os
.
WNOHANG
)
self
.
assertEqual
(
0
,
pid
)
self
.
assertEqual
(
0
,
status
)
self
.
assertEqual
(
0
,
sum
(
rusage
))
finally
:
proc
.
stdin
.
close
()
proc
.
wait
()
def
tearDownModule
():
reap_children
()
...
...
Misc/NEWS.d/next/Core and Builtins/2019-08-04-12-24-18.bpo-36279.8Zy7jZ.rst
0 → 100644
View file @
682107cf
Fix potential use of uninitialized memory in :func:`os.wait3`.
Modules/posixmodule.c
View file @
682107cf
...
...
@@ -7489,6 +7489,12 @@ wait_helper(pid_t pid, int status, struct rusage *ru)
if
(
pid
==
-
1
)
return
posix_error
();
// If wait succeeded but no child was ready to report status, ru will not
// have been populated.
if
(
pid
==
0
)
{
memset
(
ru
,
0
,
sizeof
(
*
ru
));
}
if
(
struct_rusage
==
NULL
)
{
PyObject
*
m
=
PyImport_ImportModuleNoBlock
(
"resource"
);
if
(
m
==
NULL
)
...
...
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