Skip to content

Conversation

@rcsanchez97
Copy link
Contributor

This PR fixes some small Coverity issues (w/ full Evergreen patch build).

@kevinAlbs I wasn't sure who would be available to review, so please feel free to adjust the reviewers as needed.

@rcsanchez97 rcsanchez97 changed the title Coverity fixes CDRIVER-5756 Coverity fixes Feb 15, 2025
Copy link
Contributor

@vector-of-bool vector-of-bool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments and questions.

Comment on lines 314 to 319
bson_mutex_lock (&topology->tpld_modification_mtx);
for (size_t i = 0u; i < n_rtt_monitors; i++) {
server_monitor = mongoc_set_get_item (topology->rtt_monitors, i);
mongoc_server_monitor_request_shutdown (server_monitor);
}
bson_mutex_unlock (&topology->tpld_modification_mtx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this mutex is relevant here. Do you have a link to the Coverity warning related to these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent you the link in a DM.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suspect there are existing thread-safety issues in _mongoc_topology_background_monitoring_stop.

I suspect between storing the lengths and accessing the sets, the set of server monitors could possibly change (via _mongoc_topology_background_monitoring_reconcile.

I recommend reverting this change. A more comprehensive fix can be done in the future to address the coverity warning.

@rcsanchez97 rcsanchez97 requested a review from a team as a code owner May 5, 2025 21:02
@rcsanchez97 rcsanchez97 requested a review from kevinAlbs May 5, 2025 21:02
@rcsanchez97
Copy link
Contributor Author

Here is the patch build for the latest changes.

Also, I have checked the Coverity dashboard and there are no new detections that need to be addressed.

@rcsanchez97 rcsanchez97 requested a review from kevinAlbs June 12, 2025 19:30
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for delayed review.

Comment on lines 314 to 319
bson_mutex_lock (&topology->tpld_modification_mtx);
for (size_t i = 0u; i < n_rtt_monitors; i++) {
server_monitor = mongoc_set_get_item (topology->rtt_monitors, i);
mongoc_server_monitor_request_shutdown (server_monitor);
}
bson_mutex_unlock (&topology->tpld_modification_mtx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suspect there are existing thread-safety issues in _mongoc_topology_background_monitoring_stop.

I suspect between storing the lengths and accessing the sets, the set of server monitors could possibly change (via _mongoc_topology_background_monitoring_reconcile.

I recommend reverting this change. A more comprehensive fix can be done in the future to address the coverity warning.

@rcsanchez97
Copy link
Contributor Author

Here is the patch build for the latest changes.

@rcsanchez97 rcsanchez97 requested a review from kevinAlbs July 14, 2025 15:00
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Suggest running git merge master to fix conflicts on this branch prior to merging (it looks like some of the argument asserts were already added).

@rcsanchez97 rcsanchez97 requested review from eramongodb and removed request for eramongodb and vector-of-bool July 15, 2025 17:38
@rcsanchez97
Copy link
Contributor Author

I discussed with @vector-of-bool in Slack and he said he doesn't feel like he needs to review this again, so I have removed the request for his review.

@rcsanchez97 rcsanchez97 merged commit 67a62bf into mongodb:master Jul 15, 2025
38 of 40 checks passed
@rcsanchez97 rcsanchez97 deleted the coverity_fixes branch July 15, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants