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

ASAN, memory leak #79955

Closed
DhirajMishra mannequin opened this issue Jan 18, 2019 · 2 comments
Closed

ASAN, memory leak #79955

DhirajMishra mannequin opened this issue Jan 18, 2019 · 2 comments
Labels
3.8 only security fixes type-security A security issue

Comments

@DhirajMishra
Copy link
Mannequin

DhirajMishra mannequin commented Jan 18, 2019

BPO 35774
Nosy @gpshead, @vstinner
Superseder
  • bpo-1635741: Py_Finalize() doesn't clear all Python objects at exit
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-01-28.02:24:27.530>
    created_at = <Date 2019-01-18.12:28:26.605>
    labels = ['type-security', '3.8']
    title = 'ASAN, memory leak'
    updated_at = <Date 2022-01-28.02:24:27.527>
    user = 'https://bugs.python.org/DhirajMishra'

    bugs.python.org fields:

    activity = <Date 2022-01-28.02:24:27.527>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-01-28.02:24:27.530>
    closer = 'vstinner'
    components = []
    creation = <Date 2019-01-18.12:28:26.605>
    creator = 'Dhiraj_Mishra'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35774
    keywords = []
    message_count = 2.0
    messages = ['333958', '411960']
    nosy_count = 3.0
    nosy_names = ['gregory.p.smith', 'vstinner', 'Dhiraj_Mishra']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '1635741'
    type = 'security'
    url = 'https://bugs.python.org/issue35774'
    versions = ['Python 3.8']

    @DhirajMishra
    Copy link
    Mannequin Author

    DhirajMishra mannequin commented Jan 18, 2019

    Hi Team,

    I have compiled cpython via clang using ASAN and memory leak was observed.

    After successful build of python,

    1. Run python
    2. Ctrl + D

    ==21461==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 257790 byte(s) in 93 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12

    Direct leak of 1640 byte(s) in 3 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12
    #4 0x96cea4 in _PyObject_GC_Malloc /home/input0/Desktop/cpython/Modules/gcmodule.c:1908:12
    #5 0x96cea4 in _PyObject_GC_NewVar /home/input0/Desktop/cpython/Modules/gcmodule.c:1937

    Direct leak of 663 byte(s) in 1 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12
    #4 0x8b9dd8 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1362:20
    #5 0x8b84a5 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1194:18
    #6 0x8b9e09 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1365:22
    #7 0x8bf86a in read_object /home/input0/Desktop/cpython/Python/marshal.c:1451:9
    #8 0x8bf86a in marshal_loads_impl /home/input0/Desktop/cpython/Python/marshal.c:1763
    #9 0x8bf86a in marshal_loads /home/input0/Desktop/cpython/Python/clinic/marshal.c.h:158
    #10 0x564da7 in _PyMethodDef_RawFastCallKeywords /home/input0/Desktop/cpython/Objects/call.c

    Direct leak of 579 byte(s) in 1 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12
    #4 0x8b9dd8 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1362:20
    #5 0x8b84a5 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1194:18
    #6 0x8b9e09 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1365:22
    #7 0x8b84a5 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1194:18
    #8 0x8b9e09 in r_object /home/input0/Desktop/cpython/Python/marshal.c:1365:22
    #9 0x8b409d in PyMarshal_ReadObjectFromString /home/input0/Desktop/cpython/Python/marshal.c:1568:14
    #10 0x8a0d81 in get_frozen_object /home/input0/Desktop/cpython/Python/import.c:1277:12
    #11 0x8a0d81 in _imp_get_frozen_object_impl /home/input0/Desktop/cpython/Python/import.c:2036
    #12 0x8a0d81 in _imp_get_frozen_object /home/input0/Desktop/cpython/Python/clinic/import.c.h:198
    #13 0x5623eb in _PyCFunction_FastCallDict /home/input0/Desktop/cpython/Objects/call.c:584:14
    #14 0x5623eb in PyCFunction_Call /home/input0/Desktop/cpython/Objects/call.c:789

    Direct leak of 536 byte(s) in 1 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x6403b0 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x6403b0 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x6403b0 in pymalloc_realloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1869
    #4 0x6403b0 in _PyObject_Realloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1888
    #5 0x644ead in PyObject_Realloc /home/input0/Desktop/cpython/Objects/obmalloc.c:658:12

    Indirect leak of 15640 byte(s) in 17 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12
    #4 0x675f9a in PyType_GenericAlloc /home/input0/Desktop/cpython/Objects/typeobject.c:975:15

    Indirect leak of 7440 byte(s) in 7 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12

    Indirect leak of 2571 byte(s) in 2 object(s) allocated from:
    #0 0x4f1460 in malloc (/home/input0/Desktop/cpython/python+0x4f1460)
    #1 0x63fc59 in PyMem_RawMalloc /home/input0/Desktop/cpython/Objects/obmalloc.c:527:12
    #2 0x63fc59 in _PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:1550
    #3 0x644d77 in PyObject_Malloc /home/input0/Desktop/cpython/Objects/obmalloc.c:640:12
    #4 0x687d07 in type_call /home/input0/Desktop/cpython/Objects/typeobject.c:934:11

    SUMMARY: AddressSanitizer: 286859 byte(s) leaked in 125 allocation(s).

    @DhirajMishra DhirajMishra mannequin added 3.8 only security fixes type-security A security issue labels Jan 18, 2019
    @vstinner
    Copy link
    Member

    1. Run python
    2. Ctrl + D

    It seems like this scenario has recently been fixed in bpo-1635741:

    $ ./python -I -X showrefcount 
    Python 3.11.0a4+ (heads/main:18ea973c21, Jan 28 2022, 01:38:10) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> exit()
    [-4 refs, 1 blocks]

    If you still see memory leaks in Python 3.11, please better describe what you do to "Run python" and open a new issue ;-)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes type-security A security issue
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant