Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug leak of "match_args" in StructMeta. #684

Merged
merged 1 commit into from
May 10, 2024
Merged

Commits on May 10, 2024

  1. Plug leak of "match_args" in StructMeta.

    "match_args" is set in StructMetaInfo and eventually StructMeta via -
    
    ```
     info->match_args = PyTuple_GetSlice(info->fields, 0, nfields - nkwonly);
    ```
    
    This is incref'd before copying to StructMeta, and decref'd when
    cleaning up StructMetaInfo. There's no corresponding decref for
    StructMeta itself. This causes a leak that valgrind readily detects:
    
    ```
    env PYTHONMALLOC=malloc valgrind python3 -c 'import msgspec'
    ...
    ==576283== LEAK SUMMARY:
    ==576283==    definitely lost: 1,608 bytes in 26 blocks
    ```
    
    With the fix in place, we get:
    
    ```
    ==576086== LEAK SUMMARY:
    ==576086==    definitely lost: 0 bytes in 0 blocks
    ```
    peadar committed May 10, 2024
    Configuration menu
    Copy the full SHA
    f7a85f0 View commit details
    Browse the repository at this point in the history