GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Memory leak in `hmac` module with HACL* backend detected by AddressSanitizer · Issue #140120 · python/cpython

Memory leak in hmac module with HACL* backend detected by AddressSanitizer #140120

New issue
Copy link
New issue
Copy link
Closed
Closed
Memory leak in hmac module with HACL* backend detected by AddressSanitizer#140120
Copy link
Assignees
gpshead
Labels
3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@ashm-dev
ashm-dev
opened on Oct 14, 2025
Issue body actions

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 (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.

Steps to Reproduce:

  1. Configure the build with the following flags to enable debugging and AddressSanitizer:

    CC=clang CXX=clang++ \
    ./configure \
    --disable-optimizations \
    --with-valgrind \
    --with-pydebug \
    --enable-pystats \
    --with-address-sanitizer
  2. Build CPython:

    make -j$(nproc)
  3. Run the hmac test suite:

    ./python -m test test_hmac

System Information:

  • OS: Ubuntu 25.04 (Plucky Puffin)
  • Kernel: Linux huawei 6.14.0-33-generic #33-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 17 23:22:02 UTC 2025 x86_64
  • Clang Version: Ubuntu clang version 20.1.2 (0ubuntu1)

ASan Leak Report:

test.log

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

  • gh-140120: Fix memory leak in HMAC digest #140124
  • gh-140120: Refresh HACL* #140188
  • [3.14] gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188) #140192

Activity

  1. ashm-dev
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 14, 2025
  2. StanFromIreland
    added
    performancePerformance or resource usagePerformance or resource usage
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Oct 14, 2025
  3. gpshead commented on Oct 14, 2025

    @gpshead
    gpshead
    on Oct 14, 2025
    Member
    More actions

    patch from upstream hacl* needed - #140124 (comment)

    Reacted by Stan Ulbrych
  4. protz commented on Oct 15, 2025

    @protz
    protz
    on Oct 15, 2025
    Contributor
    More actions

    Thanks for the heads-up. Is there any more precise information as to where the issue occurs? Do we know which allocation is not freed?

    CC @R1kM

  5. protz commented on Oct 15, 2025

    @protz
    protz
    on Oct 15, 2025
    Contributor
    More actions

    Oh I see the patch is in https://github.com/python/cpython/pull/140124/files -- let me look into this.

    Reacted by Gregory P. Smith
  6. protz commented on Oct 15, 2025

    @protz
    protz
    on Oct 15, 2025
    Contributor
    More actions

    hacl-star/hacl-star#1064 has been merged so the next refresh of HACL* will have the fix. Thanks for reporting!

    Reacted by Shamil and Gregory P. Smith
  7. gpshead
    self-assigned this
    on Oct 16, 2025
  8. gpshead
    added a commit that references this issue on Oct 16, 2025

    gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188)

    3a81313
  9. miss-islington
    added a commit that references this issue on Oct 16, 2025

    pythongh-140120: Refresh HACL* to fix an hmac memory leak (pythonGH-1…

    c1dc5eb
  10. ashm-dev commented on Oct 16, 2025

    @ashm-dev
    ashm-dev
    on Oct 16, 2025
    ContributorAuthor
    More actions

    I checked, there are no more leaks, thank you!

    Reacted by Sergey Miryanov
    Reacted by Gregory P. Smith
  11. gpshead
    added a commit that references this issue on Oct 17, 2025

    [3.14] gh-140120: Refresh HACL* to fix an hmac memory leak (GH-140188) (

    32e60fa
  12. gpshead commented on Oct 17, 2025

    @gpshead
    gpshead
    on Oct 17, 2025
    Member
    More actions

    yay, thanks for finding this!

  13. gpshead
    closed this as completedon Oct 17, 2025
  14. gpshead
    added
    3.14bugs and security fixesbugs and security fixes
    on Oct 17, 2025
  15. StanFromIreland
    added a commit that references this issue on Dec 6, 2025

    pythongh-140120: Refresh HACL* to fix an hmac memory leak (pythonGH-1…

    e417226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @gpshead
    gpshead

Labels

3.14bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.