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
62300c69
Commit
62300c69
authored
Apr 22, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interpreter+bjit: fix leak when encountering a dict or set node with duplicate keys
parent
30d2e36c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
7 deletions
+23
-7
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+11
-2
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+10
-3
test/tests/dict.py
test/tests/dict.py
+1
-1
test/tests/set.py
test/tests/set.py
+1
-1
No files found.
src/codegen/ast_interpreter.cpp
View file @
62300c69
...
...
@@ -1574,8 +1574,13 @@ Value ASTInterpreter::visit_dict(AST_Dict* node) {
BoxedDict
*
dict
=
new
BoxedDict
();
for
(
size_t
i
=
0
;
i
<
node
->
keys
.
size
();
++
i
)
{
Value
v
=
visit_expr
(
node
->
values
[
i
]);
AUTO_DECREF
(
v
.
o
);
Value
k
=
visit_expr
(
node
->
keys
[
i
]);
dict
->
d
[
k
.
o
]
=
v
.
o
;
AUTO_DECREF
(
k
.
o
);
int
ret
=
PyDict_SetItem
(
dict
,
k
.
o
,
v
.
o
);
if
(
ret
==
-
1
)
throwCAPIException
();
values
.
push_back
(
v
);
keys
.
push_back
(
k
);
...
...
@@ -1590,7 +1595,11 @@ Value ASTInterpreter::visit_set(AST_Set* node) {
BoxedSet
::
Set
set
;
for
(
AST_expr
*
e
:
node
->
elts
)
{
Value
v
=
visit_expr
(
e
);
set
.
insert
(
v
.
o
);
auto
&&
p
=
set
.
insert
(
v
.
o
);
if
(
!
p
.
second
/* already exists */
)
{
Py_DECREF
(
p
.
first
->
value
);
*
p
.
first
=
v
.
o
;
}
items
.
push_back
(
v
);
}
...
...
src/codegen/baseline_jit.cpp
View file @
62300c69
...
...
@@ -854,7 +854,9 @@ Box* JitFragmentWriter::callattrHelper(Box* obj, BoxedString* attr, CallattrFlag
Box
*
JitFragmentWriter
::
createDictHelper
(
uint64_t
num
,
Box
**
keys
,
Box
**
values
)
{
BoxedDict
*
dict
=
(
BoxedDict
*
)
createDict
();
for
(
uint64_t
i
=
0
;
i
<
num
;
++
i
)
{
dict
->
d
[
keys
[
i
]]
=
values
[
i
];
int
ret
=
PyDict_SetItem
(
dict
,
autoDecref
(
keys
[
i
]),
autoDecref
(
values
[
i
]));
if
(
ret
==
-
1
)
throwCAPIException
();
}
return
dict
;
}
...
...
@@ -870,8 +872,13 @@ Box* JitFragmentWriter::createListHelper(uint64_t num, Box** data) {
Box
*
JitFragmentWriter
::
createSetHelper
(
uint64_t
num
,
Box
**
data
)
{
BoxedSet
*
set
=
(
BoxedSet
*
)
createSet
();
for
(
int
i
=
0
;
i
<
num
;
++
i
)
set
->
s
.
insert
(
data
[
i
]);
for
(
int
i
=
0
;
i
<
num
;
++
i
)
{
auto
&&
p
=
set
->
s
.
insert
(
data
[
i
]);
if
(
!
p
.
second
/* already exists */
)
{
Py_DECREF
(
p
.
first
->
value
);
*
p
.
first
=
data
[
i
];
}
}
return
set
;
}
...
...
test/tests/dict.py
View file @
62300c69
d
=
{
2
:
2
}
d
=
{
2
:
"should get overwritten"
,
2
:
2
}
d
[
1
]
=
1
print
d
print
d
[
1
],
d
[
1L
],
d
[
1.0
],
d
[
True
]
...
...
test/tests/set.py
View file @
62300c69
s1
=
{
1
}
s1
=
{
1
,
1
}
def
sorted
(
s
):
l
=
list
(
s
)
...
...
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