Adding comment re potential use_count data race.

parent 6294eb26
...@@ -131,6 +131,10 @@ struct smart_holder { ...@@ -131,6 +131,10 @@ struct smart_holder {
throw std::runtime_error(std::string("Cannot disown nullptr (") + context + ")."); throw std::runtime_error(std::string("Cannot disown nullptr (") + context + ").");
} }
if (vptr.use_count() != 1) { 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 throw std::runtime_error(std::string("Cannot disown use_count != 1 (") + context
+ ")."); + ").");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment