Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
9b94ee3b
Commit
9b94ee3b
authored
Mar 28, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix refcounts when exceptions are thrown in rearrangeArguments
parent
348e7637
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+24
-1
No files found.
src/runtime/objmodel.cpp
View file @
9b94ee3b
...
@@ -3921,6 +3921,18 @@ ArgPassSpec bindObjIntoArgs(Box* bind_obj, RewriterVar* r_bind_obj, _CallRewrite
...
@@ -3921,6 +3921,18 @@ ArgPassSpec bindObjIntoArgs(Box* bind_obj, RewriterVar* r_bind_obj, _CallRewrite
return
ArgPassSpec
(
argspec
.
num_args
+
1
,
argspec
.
num_keywords
,
argspec
.
has_starargs
,
argspec
.
has_kwargs
);
return
ArgPassSpec
(
argspec
.
num_args
+
1
,
argspec
.
num_keywords
,
argspec
.
has_starargs
,
argspec
.
has_kwargs
);
}
}
template
<
typename
FT
>
class
ExceptionCleanup
{
private:
FT
functor
;
public:
ExceptionCleanup
(
FT
ft
)
:
functor
(
std
::
move
(
ft
))
{}
~
ExceptionCleanup
()
{
if
(
isUnwinding
())
functor
();
}
};
template
<
Rewritable
rewritable
,
typename
FuncNameCB
>
template
<
Rewritable
rewritable
,
typename
FuncNameCB
>
void
rearrangeArgumentsInternal
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
FuncNameCB
func_name_cb
,
void
rearrangeArgumentsInternal
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
FuncNameCB
func_name_cb
,
Box
**
defaults
,
_CallRewriteArgsBase
*
rewrite_args
,
bool
&
rewrite_success
,
Box
**
defaults
,
_CallRewriteArgsBase
*
rewrite_args
,
bool
&
rewrite_success
,
...
@@ -4035,6 +4047,18 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
...
@@ -4035,6 +4047,18 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
Box
*
arg3
=
oarg3
;
Box
*
arg3
=
oarg3
;
oarg1
=
oarg2
=
oarg3
=
NULL
;
oarg1
=
oarg2
=
oarg3
=
NULL
;
// Clear any increfs we did for when we throw an exception:
auto
clear_refs
=
[
&
]()
{
Py_XDECREF
(
oarg1
);
Py_XDECREF
(
oarg2
);
Py_XDECREF
(
oarg3
);
for
(
int
i
=
0
;
i
<
num_output_args
-
3
;
i
++
)
{
Py_XDECREF
(
oargs
[
i
]);
}
};
ExceptionCleanup
<
decltype
(
clear_refs
)
>
cleanup
(
clear_refs
);
// I feel like there should be some way to automatically infer the decltype
static
StatCounter
slowpath_rearrangeargs_slowpath
(
"slowpath_rearrangeargs_slowpath"
);
static
StatCounter
slowpath_rearrangeargs_slowpath
(
"slowpath_rearrangeargs_slowpath"
);
slowpath_rearrangeargs_slowpath
.
log
();
slowpath_rearrangeargs_slowpath
.
log
();
...
@@ -4344,7 +4368,6 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
...
@@ -4344,7 +4368,6 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
for
(
int
i
=
0
;
i
<
paramspec
.
num_args
-
paramspec
.
num_defaults
;
i
++
)
{
for
(
int
i
=
0
;
i
<
paramspec
.
num_args
-
paramspec
.
num_defaults
;
i
++
)
{
if
(
params_filled
[
i
])
if
(
params_filled
[
i
])
continue
;
continue
;
RELEASE_ASSERT
(
0
,
"TODO: decref everything that we incref'd as part of this process"
);
raiseExcHelper
(
TypeError
,
"%s() takes exactly %d arguments (%ld given)"
,
func_name_cb
(),
paramspec
.
num_args
,
raiseExcHelper
(
TypeError
,
"%s() takes exactly %d arguments (%ld given)"
,
func_name_cb
(),
paramspec
.
num_args
,
argspec
.
num_args
+
argspec
.
num_keywords
+
varargs_size
);
argspec
.
num_args
+
argspec
.
num_keywords
+
varargs_size
);
}
}
...
...
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