mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
gh-136870: fix data races in instrumentation of bytecode (#136994)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run
De-instrumenting code objects modifies the thread local bytecode for all threads as such, holding the critical section on the code object is not sufficient and leads to data races. Now, the de-instrumentation is now performed under a stop the world pause as such no thread races with executing the thread local bytecode while it is being de-instrumented.
This commit is contained in:
parent
245671555b
commit
9a6b60af40
2 changed files with 13 additions and 8 deletions
|
|
@ -1190,9 +1190,10 @@ call_instrumentation_vector(
|
|||
break;
|
||||
}
|
||||
else {
|
||||
LOCK_CODE(code);
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
_PyEval_StopTheWorld(interp);
|
||||
remove_tools(code, offset, event, 1 << tool);
|
||||
UNLOCK_CODE();
|
||||
_PyEval_StartTheWorld(interp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1381,9 +1382,10 @@ _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame,
|
|||
}
|
||||
else {
|
||||
/* DISABLE */
|
||||
LOCK_CODE(code);
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
_PyEval_StopTheWorld(interp);
|
||||
remove_line_tools(code, i, 1 << tool);
|
||||
UNLOCK_CODE();
|
||||
_PyEval_StartTheWorld(interp);
|
||||
}
|
||||
} while (tools);
|
||||
Py_DECREF(line_obj);
|
||||
|
|
@ -1438,9 +1440,10 @@ _Py_call_instrumentation_instruction(PyThreadState *tstate, _PyInterpreterFrame*
|
|||
}
|
||||
else {
|
||||
/* DISABLE */
|
||||
LOCK_CODE(code);
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
_PyEval_StopTheWorld(interp);
|
||||
remove_per_instruction_tools(code, offset, 1 << tool);
|
||||
UNLOCK_CODE();
|
||||
_PyEval_StartTheWorld(interp);
|
||||
}
|
||||
}
|
||||
Py_DECREF(offset_obj);
|
||||
|
|
@ -2995,9 +2998,10 @@ branch_handler_vectorcall(
|
|||
// Orphaned NOT_TAKEN -- Jump removed by the compiler
|
||||
return res;
|
||||
}
|
||||
LOCK_CODE(code);
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
_PyEval_StopTheWorld(interp);
|
||||
remove_tools(code, offset, other_event, 1 << self->tool_id);
|
||||
UNLOCK_CODE();
|
||||
_PyEval_StartTheWorld(interp);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue