mirror of
https://github.com/pybind/pybind11.git
synced 2024-12-01 17:37:15 +00:00
Adding comment re potential use_count data race.
This commit is contained in:
parent
6294eb26e5
commit
649eb91f21
@ -131,6 +131,10 @@ struct smart_holder {
|
||||
throw std::runtime_error(std::string("Cannot disown nullptr (") + context + ").");
|
||||
}
|
||||
if (vptr.use_count() != 1) {
|
||||
// In multithreaded environments accessing use_count is racy,
|
||||
// but in the context of Python it is a bug (elsewhere) if the
|
||||
// Global Interpreter Lock (GIL) is not being held when this code
|
||||
// is reached.
|
||||
throw std::runtime_error(std::string("Cannot disown use_count != 1 (") + context
|
||||
+ ").");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user