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
03221545
Commit
03221545
authored
Aug 12, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport r60148 and r65481: sanity checks to avoid infinite loops.
parent
1576bab0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
Python/pystate.c
Python/pystate.c
+14
-0
Python/thread.c
Python/thread.c
+11
-1
No files found.
Python/pystate.c
View file @
03221545
...
...
@@ -240,6 +240,7 @@ tstate_delete_common(PyThreadState *tstate)
{
PyInterpreterState
*
interp
;
PyThreadState
**
p
;
PyThreadState
*
prev_p
=
NULL
;
if
(
tstate
==
NULL
)
Py_FatalError
(
"PyThreadState_Delete: NULL tstate"
);
interp
=
tstate
->
interp
;
...
...
@@ -252,6 +253,19 @@ tstate_delete_common(PyThreadState *tstate)
"PyThreadState_Delete: invalid tstate"
);
if
(
*
p
==
tstate
)
break
;
/* Sanity check. These states should never happen but if
* they do we must abort. Otherwise we'll end up spinning in
* in a tight loop with the lock held. A similar check is done
* in thread.c find_key(). */
if
(
*
p
==
prev_p
)
Py_FatalError
(
"PyThreadState_Delete: small circular list(!)"
" and tstate not found."
);
prev_p
=
*
p
;
if
((
*
p
)
->
next
==
interp
->
tstate_head
)
Py_FatalError
(
"PyThreadState_Delete: circular list(!) and"
" tstate not found."
);
}
*
p
=
tstate
->
next
;
HEAD_UNLOCK
();
...
...
Python/thread.c
View file @
03221545
...
...
@@ -264,15 +264,25 @@ static int nkeys = 0; /* PyThread_create_key() hands out nkeys+1 next */
static
struct
key
*
find_key
(
int
key
,
void
*
value
)
{
struct
key
*
p
;
struct
key
*
p
,
*
prev_p
;
long
id
=
PyThread_get_thread_ident
();
if
(
!
keymutex
)
return
NULL
;
PyThread_acquire_lock
(
keymutex
,
1
);
prev_p
=
NULL
;
for
(
p
=
keyhead
;
p
!=
NULL
;
p
=
p
->
next
)
{
if
(
p
->
id
==
id
&&
p
->
key
==
key
)
goto
Done
;
/* Sanity check. These states should never happen but if
* they do we must abort. Otherwise we'll end up spinning in
* in a tight loop with the lock held. A similar check is done
* in pystate.c tstate_delete_common(). */
if
(
p
==
prev_p
)
Py_FatalError
(
"tls find_key: small circular list(!)"
);
prev_p
=
p
;
if
(
p
->
next
==
keyhead
)
Py_FatalError
(
"tls find_key: circular list(!)"
);
}
if
(
value
==
NULL
)
{
assert
(
p
==
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