mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-138661: fix data race in PyCode_Addr2Line
(#138664)
This commit is contained in:
parent
c3fca5d478
commit
ea26f6da39
3 changed files with 15 additions and 3 deletions
|
@ -274,6 +274,8 @@ extern void _PyLineTable_InitAddressRange(
|
|||
/** API for traversing the line number table. */
|
||||
extern int _PyLineTable_NextAddressRange(PyCodeAddressRange *range);
|
||||
extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
|
||||
// This is used in dump_frame() in traceback.c without an attached tstate.
|
||||
extern int _PyCode_Addr2LineNoTstate(PyCodeObject *co, int addr);
|
||||
|
||||
/** API for executors */
|
||||
extern void _PyCode_Clear_Executors(PyCodeObject *code);
|
||||
|
|
|
@ -1006,7 +1006,7 @@ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno)
|
|||
******************/
|
||||
|
||||
int
|
||||
PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
||||
_PyCode_Addr2LineNoTstate(PyCodeObject *co, int addrq)
|
||||
{
|
||||
if (addrq < 0) {
|
||||
return co->co_firstlineno;
|
||||
|
@ -1020,6 +1020,16 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
|||
return _PyCode_CheckLineNumber(addrq, &bounds);
|
||||
}
|
||||
|
||||
int
|
||||
PyCode_Addr2Line(PyCodeObject *co, int addrq)
|
||||
{
|
||||
int lineno;
|
||||
Py_BEGIN_CRITICAL_SECTION(co);
|
||||
lineno = _PyCode_Addr2LineNoTstate(co, addrq);
|
||||
Py_END_CRITICAL_SECTION();
|
||||
return lineno;
|
||||
}
|
||||
|
||||
void
|
||||
_PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range)
|
||||
{
|
||||
|
|
|
@ -993,8 +993,8 @@ dump_frame(int fd, _PyInterpreterFrame *frame)
|
|||
} else {
|
||||
PUTS(fd, "???");
|
||||
}
|
||||
|
||||
int lineno = PyUnstable_InterpreterFrame_GetLine(frame);
|
||||
int lasti = PyUnstable_InterpreterFrame_GetLasti(frame);
|
||||
int lineno = _PyCode_Addr2LineNoTstate(code, lasti);
|
||||
PUTS(fd, ", line ");
|
||||
if (lineno >= 0) {
|
||||
_Py_DumpDecimal(fd, (size_t)lineno);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue