diff --git a/include/pybind11/smart_holder_poc.h b/include/pybind11/smart_holder_poc.h index 0b70c719c..3c882ee4a 100644 --- a/include/pybind11/smart_holder_poc.h +++ b/include/pybind11/smart_holder_poc.h @@ -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 + ")."); }