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
dc303547
Commit
dc303547
authored
Jan 24, 2008
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test67.py from issue #1303614.
parent
a654b464
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
+29
-21
Lib/test/crashers/loosing_dict_ref.py
Lib/test/crashers/loosing_dict_ref.py
+0
-21
Lib/test/test_descr.py
Lib/test/test_descr.py
+24
-0
Objects/object.c
Objects/object.c
+5
-0
No files found.
Lib/test/crashers/loosing_dict_ref.py
deleted
100644 → 0
View file @
a654b464
# http://python.org/sf/1303614
class
Strange
(
object
):
def
__hash__
(
self
):
return
hash
(
'hello'
)
def
__eq__
(
self
,
other
):
x
.
__dict__
=
{}
# the old x.__dict__ is deallocated
return
False
class
X
(
object
):
pass
if
__name__
==
'__main__'
:
v
=
123
x
=
X
()
x
.
__dict__
=
{
Strange
():
42
,
'hello'
:
v
+
456
}
x
.
hello
# segfault: the above dict is accessed after it's deallocated
Lib/test/test_descr.py
View file @
dc303547
...
...
@@ -4504,6 +4504,29 @@ def test_borrowed_ref_4_segfault():
finally
:
__builtin__
.
__import__
=
orig_import
def
test_losing_dict_ref_segfault
():
# This used to segfault;
# derived from issue #1303614, test67.py
if
verbose
:
print
"Testing losing dict ref segfault..."
class
Strange
(
object
):
def
__hash__
(
self
):
return
hash
(
'hello'
)
def
__eq__
(
self
,
other
):
x
.
__dict__
=
{}
# the old x.__dict__ is deallocated
return
False
class
X
(
object
):
pass
v
=
123
x
=
X
()
x
.
__dict__
=
{
Strange
():
42
,
'hello'
:
v
+
456
}
x
.
hello
def
test_main
():
weakref_segfault
()
# Must be first, somehow
wrapper_segfault
()
...
...
@@ -4606,6 +4629,7 @@ def test_main():
test_weakref_in_del_segfault
()
test_borrowed_ref_3_segfault
()
test_borrowed_ref_4_segfault
()
test_losing_dict_ref_segfault
()
if
verbose
:
print
"All OK"
...
...
Objects/object.c
View file @
dc303547
...
...
@@ -1349,12 +1349,15 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
dictptr
=
(
PyObject
**
)
((
char
*
)
obj
+
dictoffset
);
dict
=
*
dictptr
;
if
(
dict
!=
NULL
)
{
Py_INCREF
(
dict
);
res
=
PyDict_GetItem
(
dict
,
name
);
if
(
res
!=
NULL
)
{
Py_INCREF
(
res
);
Py_XDECREF
(
descr
);
Py_DECREF
(
dict
);
goto
done
;
}
Py_DECREF
(
dict
);
}
}
...
...
@@ -1435,12 +1438,14 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
*
dictptr
=
dict
;
}
if
(
dict
!=
NULL
)
{
Py_INCREF
(
dict
);
if
(
value
==
NULL
)
res
=
PyDict_DelItem
(
dict
,
name
);
else
res
=
PyDict_SetItem
(
dict
,
name
,
value
);
if
(
res
<
0
&&
PyErr_ExceptionMatches
(
PyExc_KeyError
))
PyErr_SetObject
(
PyExc_AttributeError
,
name
);
Py_DECREF
(
dict
);
goto
done
;
}
}
...
...
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