Title: Memory leak in `hmac` module with HACL* backend detected by AddressSanitizer · Issue #140120 · python/cpython · GitHub
Open Graph Title: Memory leak in `hmac` module with HACL* backend detected by AddressSanitizer · Issue #140120 · python/cpython
X Title: Memory leak in `hmac` module with HACL* backend detected by AddressSanitizer · Issue #140120 · python/cpython
Description: Bug report Bug Description: A memory leak has been detected in the hmac module when running test_hmac. The issue appears to be specific to the Hacl_Streaming_HMAC implementation, as indicated by the stack traces from the AddressSanitizer...
Open Graph Description: Bug report Bug Description: A memory leak has been detected in the hmac module when running test_hmac. The issue appears to be specific to the Hacl_Streaming_HMAC implementation, as indicated by th...
X Description: Bug report Bug Description: A memory leak has been detected in the hmac module when running test_hmac. The issue appears to be specific to the Hacl_Streaming_HMAC implementation, as indicated by th...
Opengraph URL: https://github.com/python/cpython/issues/140120
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak in `hmac` module with HACL* backend detected by AddressSanitizer","articleBody":"# Bug report\n\n### **Bug Description:**\n\nA memory leak has been detected in the `hmac` module when running `test_hmac`. The issue appears to be specific to the `Hacl_Streaming_HMAC` implementation, as indicated by the stack traces from the AddressSanitizer (ASan) report. The leaks occur within functions responsible for HMAC digest computation (`_Py_LibHacl_Hacl_Streaming_HMAC_digest`, `hmac_digest_compute_locked`), suggesting that memory allocated during these operations is not being properly deallocated.\n\n**Steps to Reproduce:**\n\n1. Configure the build with the following flags to enable debugging and AddressSanitizer:\n ```bash\n CC=clang CXX=clang++ \\\n ./configure \\\n --disable-optimizations \\\n --with-valgrind \\\n --with-pydebug \\\n --enable-pystats \\\n --with-address-sanitizer\n ```\n\n2. Build CPython:\n ```bash\n make -j$(nproc)\n ```\n\n3. Run the `hmac` test suite:\n ```bash\n ./python -m test test_hmac\n ```\n\n**System Information:**\n* **OS:** `Ubuntu 25.04 (Plucky Puffin)`\n* **Kernel:** `Linux huawei 6.14.0-33-generic #33-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 17 23:22:02 UTC 2025 x86_64`\n* **Clang Version:** `Ubuntu clang version 20.1.2 (0ubuntu1)`\n\n**ASan Leak Report:**\n\n[test.log](https://github.com/user-attachments/files/22907996/test.log)\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-140124\n* gh-140188\n* gh-140192\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ashm-dev","@type":"Person","name":"ashm-dev"},"datePublished":"2025-10-14T15:25:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/140120/cpython/issues/140120"}
| 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:4a6c3249-1f1b-c22c-6ce4-a7fec2db5c54 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C108:1F1AF5:B914CA:FD5007:6969F32F |
| html-safe-nonce | 439fffe9494410fb784d8fd302822f0bcad1445f03dc8f0355a3335872db5675 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTA4OjFGMUFGNTpCOTE0Q0E6RkQ1MDA3OjY5NjlGMzJGIiwidmlzaXRvcl9pZCI6IjEyNjgyMzQ2Mzk0NjkzMTA3NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1f352886b2781c0d165fb994a802fa6751d6dceaba240e36ba5ced7a60f7cf63 |
| hovercard-subject-tag | issue:3514430846 |
| 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/python/cpython/140120/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56a6e35c3fd841dfd6986d8b5ca48b90c89b99585445b61d338b9c9072fdb8b3/python/cpython/issues/140120 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56a6e35c3fd841dfd6986d8b5ca48b90c89b99585445b61d338b9c9072fdb8b3/python/cpython/issues/140120 |
| og:image:alt | Bug report Bug Description: A memory leak has been detected in the hmac module when running test_hmac. The issue appears to be specific to the Hacl_Streaming_HMAC implementation, as indicated by th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ashm-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width