Title: `CON51-CPP`: Falsely reports potential leaks of std::lock_guard · Issue #972 · github/codeql-coding-standards · GitHub
Open Graph Title: `CON51-CPP`: Falsely reports potential leaks of std::lock_guard · Issue #972 · github/codeql-coding-standards
X Title: `CON51-CPP`: Falsely reports potential leaks of std::lock_guard · Issue #972 · github/codeql-coding-standards
Description: Affected rules 'CON51-CPP' Description The description of CON51-CPP recommends that users use std::lock_guard to avoid leaking locked mutexes when an exception occurs. However, it seems that this rule was likely implemented before we sup...
Open Graph Description: Affected rules 'CON51-CPP' Description The description of CON51-CPP recommends that users use std::lock_guard to avoid leaking locked mutexes when an exception occurs. However, it seems that this r...
X Description: Affected rules 'CON51-CPP' Description The description of CON51-CPP recommends that users use std::lock_guard to avoid leaking locked mutexes when an exception occurs. However, it seems tha...
Opengraph URL: https://github.com/github/codeql-coding-standards/issues/972
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`CON51-CPP`: Falsely reports potential leaks of std::lock_guard","articleBody":"### Affected rules\n - 'CON51-CPP'\n\n### Description\n\nThe description of CON51-CPP recommends that users use `std::lock_guard` to avoid leaking locked mutexes when an exception occurs. However, it seems that this rule was likely implemented before we supported `std::lock_guard` in our `LockProtectedControlFlowNode` class, and it assumes all locks require a catch block. Most likely, we later added support for std::lock_guard and didn't update this rule to allow `LockProtectedControlFlowNode`s without catch blocks when the lock cannot leak.\n\n### Example\n\n```cpp\nvoid example_function(std::mutex\u0026 m) {\n std::lock_guard\u003cstd::mutex\u003e lg(m);\n\n // alert is falsely reported that this function requires a catch block to unlock lg.\n return;\n}\n```\n","author":{"url":"https://github.com/MichaelRFairhurst","@type":"Person","name":"MichaelRFairhurst"},"datePublished":"2025-11-19T23:55:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/972/codeql-coding-standards/issues/972"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d7a1603a-f06b-524a-5304-041708ad85a0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A0C:155208:19B029:222F0C:696B614D |
| html-safe-nonce | 0479229ff0b408b584ecbdc5e324e0cf92ecca2fbc558c8fba5c7c34efc3d65c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTBDOjE1NTIwODoxOUIwMjk6MjIyRjBDOjY5NkI2MTREIiwidmlzaXRvcl9pZCI6IjQ4MzE4NTU2MjE1NjYwNjI5MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 58bd7996ee9f715a1260ca64c6cf7a9001dc64361a68f60ef2d644685c87365e |
| hovercard-subject-tag | issue:3644826340 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/codeql-coding-standards/972/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0ac4d34e8ea8c1afde5a5d7924c4cdb483dba1b971767cc18279b6fe0eb03c7a/github/codeql-coding-standards/issues/972 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0ac4d34e8ea8c1afde5a5d7924c4cdb483dba1b971767cc18279b6fe0eb03c7a/github/codeql-coding-standards/issues/972 |
| og:image:alt | Affected rules 'CON51-CPP' Description The description of CON51-CPP recommends that users use std::lock_guard to avoid leaking locked mutexes when an exception occurs. However, it seems that this r... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MichaelRFairhurst |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/github/codeql-coding-standards git https://github.com/github/codeql-coding-standards.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 513154248 |
| octolytics-dimension-repository_nwo | github/codeql-coding-standards |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 513154248 |
| octolytics-dimension-repository_network_root_nwo | github/codeql-coding-standards |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width