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: github.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:06108fd6-edad-27fc-44c2-3f09779e6706 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3B0:7FC80:18F7FC0:21A991B:6964B040 |
| html-safe-nonce | 3e32562f60f422010846fa1e2baa4b4d2b6c770a638f21ede816d8e64912427a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0IwOjdGQzgwOjE4RjdGQzA6MjFBOTkxQjo2OTY0QjA0MCIsInZpc2l0b3JfaWQiOiIyNjM0NTU4MDU4MTAzMzUzNDA4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6bd226dda7342e8871e913e67b570248ed9276d1f7ae43e39650bc21fbd9b6e0 |
| 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 | 15579c46431b7fd25941c3b09010f74fd1890c7a35226839bbbf40ce70fb3057 |
| 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 | 499abb347cb197601d399c346cfeb4b3fa135d5c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width