You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: Coverity scan issue: Possible dereferencing iterator pos though it is already past the end of its container. #4822
What version (or hash if on master) of pybind11 are you using?
2.10.2
Problem description
Scan highlights possible issue in function clear_patients in "class.h" file:
I assume the tools expects explicit check before dereferencing:
if (pos != internals.patients.end()) {
// Clearing the patients can cause more Python code to run, which// can invalidate the iterator. Extract the vector of patients// from the unordered_map first.auto patients = std::move(pos->second);
internals.patients.erase(pos);
instance->has_patients = false;
for (PyObject *&patient : patients) {
Py_CLEAR(patient);
}
} else {
assert(pos != internals.patients.end());
}
If such a change is agreeable, I'd be happy to open a PR.
Feel free to resolve this issue if you are against this change and believe this issue is a false positive in the Coverity scan.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Activity
rwgk commentedon Sep 25, 2023
Did you try this with
-UNDEBUGalready?oleksandr-pavlyk commentedon Sep 25, 2023
Yes, doing
-UNDEBUGdoes help.cliffburdick commentedon May 13, 2024
This appears to be happening with g++13 (not just coverity) now where it wasn't happening with older compilers.