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
56868f94
Commit
56868f94
authored
Jul 21, 2018
by
jdemeyer
Committed by
Serhiy Storchaka
Jul 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-34126: Fix crashes while profiling invalid calls. (GH-8300)
parent
a692efe4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
+28
-4
Lib/test/test_sys_setprofile.py
Lib/test/test_sys_setprofile.py
+16
-0
Misc/NEWS.d/next/Core and Builtins/2018-07-16-20-55-29.bpo-34126.mBVmgc.rst
...ore and Builtins/2018-07-16-20-55-29.bpo-34126.mBVmgc.rst
+2
-0
Python/ceval.c
Python/ceval.c
+10
-4
No files found.
Lib/test/test_sys_setprofile.py
View file @
56868f94
...
...
@@ -334,6 +334,22 @@ class ProfileSimulatorTestCase(TestCaseBase):
(
1
,
'return'
,
j_ident
),
])
# Test an invalid call (bpo-34126)
def
test_unbound_method_no_args
(
self
):
def
f
(
p
):
dict
.
get
()
f_ident
=
ident
(
f
)
self
.
check_events
(
f
,
[(
1
,
'call'
,
f_ident
),
(
1
,
'return'
,
f_ident
)])
# Test an invalid call (bpo-34126)
def
test_unbound_method_invalid_args
(
self
):
def
f
(
p
):
dict
.
get
(
print
,
42
)
f_ident
=
ident
(
f
)
self
.
check_events
(
f
,
[(
1
,
'call'
,
f_ident
),
(
1
,
'return'
,
f_ident
)])
def
ident
(
function
):
if
hasattr
(
function
,
"f_code"
):
...
...
Misc/NEWS.d/next/Core and Builtins/2018-07-16-20-55-29.bpo-34126.mBVmgc.rst
0 → 100644
View file @
56868f94
Fix crashes when profiling certain invalid calls of unbound methods.
Patch by Jeroen Demeyer.
Python/ceval.c
View file @
56868f94
...
...
@@ -4566,10 +4566,16 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
}
else
if
(
Py_TYPE
(
func
)
==
&
PyMethodDescr_Type
)
{
PyThreadState
*
tstate
=
PyThreadState_GET
();
if
(
tstate
->
use_tracing
&&
tstate
->
c_profilefunc
)
{
// We need to create PyCFunctionObject for tracing.
PyMethodDescrObject
*
descr
=
(
PyMethodDescrObject
*
)
func
;
func
=
PyCFunction_NewEx
(
descr
->
d_method
,
stack
[
0
],
NULL
);
if
(
nargs
>
0
&&
tstate
->
use_tracing
)
{
/* We need to create a temporary bound method as argument
for profiling.
If nargs == 0, then this cannot work because we have no
"self". In any case, the call itself would raise
TypeError (foo needs an argument), so we just skip
profiling. */
PyObject
*
self
=
stack
[
0
];
func
=
Py_TYPE
(
func
)
->
tp_descr_get
(
func
,
self
,
(
PyObject
*
)
Py_TYPE
(
self
));
if
(
func
==
NULL
)
{
return
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