Skip to content

PyConfig_Clear() doesn't clear _orig_argv member (_PyWideStringList_Copy breaks asan builds) #85125

Closed

Description

@tiran
BPO 40953
Nosy @vstinner, @tiran, @miss-islington
PRs
  • [3.9] bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886) #20887
  • 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 2020-06-15.14:38:14.134>
    created_at = <Date 2020-06-12.07:30:34.444>
    labels = ['build', '3.9', '3.10', 'performance']
    title = "PyConfig_Clear() doesn't clear _orig_argv member (_PyWideStringList_Copy breaks asan builds)"
    updated_at = <Date 2020-06-15.16:23:50.007>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2020-06-15.16:23:50.007>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-06-15.14:38:14.134>
    closer = 'vstinner'
    components = ['Build']
    creation = <Date 2020-06-12.07:30:34.444>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40953
    keywords = ['patch']
    message_count = 6.0
    messages = ['371336', '371546', '371551', '371555', '371561', '371570']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'christian.heimes', 'miss-islington']
    pr_nums = ['20887']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue40953'
    versions = ['Python 3.9', 'Python 3.10']

    Activity

    1. tiran commented on Jun 12, 2020

      @tiran
      MemberAuthor

      It's not possible to build Python with address sanitizer and memory leak checker asan.

      $ ./configure --with-address-sanitizer --with-undefined-behavior-sanitizer
      $ make
      ...
      ./python -E -S -m sysconfig --generate-posix-vars ;\
      if test $? -ne 0 ; then \
              echo "generate-posix-vars failed" ; \
              rm -f ./pybuilddir.txt ; \
              exit 1 ; \
      fi

      =================================================================
      ==1585722==ERROR: LeakSanitizer: detected memory leaks

      Direct leak of 48 byte(s) in 1 object(s) allocated from:
      #0 0x7fa404ea9667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
      #1 0x9ab398 in _PyWideStringList_Copy Python/initconfig.c:315
      #2 0x9b48bd in _PyConfig_Copy Python/initconfig.c:857
      #3 0xa20b4c in _PyInterpreterState_SetConfig Python/pystate.c:1834
      #4 0xa07a14 in pycore_create_interpreter Python/pylifecycle.c:554
      #5 0xa07a14 in pyinit_config Python/pylifecycle.c:759
      #6 0xa07a14 in pyinit_core Python/pylifecycle.c:926
      #7 0xa09b17 in Py_InitializeFromConfig Python/pylifecycle.c:1136
      #8 0x4766c2 in pymain_init Modules/main.c:66
      #9 0x47bd12 in pymain_main Modules/main.c:653
      #10 0x47bd12 in Py_BytesMain Modules/main.c:686
      #11 0x7fa404173041 in __libc_start_main (/lib64/libc.so.6+0x27041)

      Direct leak of 48 byte(s) in 1 object(s) allocated from:
      #0 0x7fa404ea9667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
      #1 0x9ab398 in _PyWideStringList_Copy Python/initconfig.c:315
      #2 0x9b8ee8 in PyConfig_Read Python/initconfig.c:2506
      #3 0xa07282 in pyinit_core Python/pylifecycle.c:920
      #4 0xa09b17 in Py_InitializeFromConfig Python/pylifecycle.c:1136
      #5 0x4766c2 in pymain_init Modules/main.c:66
      #6 0x47bd12 in pymain_main Modules/main.c:653
      #7 0x47bd12 in Py_BytesMain Modules/main.c:686
      #8 0x7fa404173041 in __libc_start_main (/lib64/libc.so.6+0x27041)

      Indirect leak of 200 byte(s) in 6 object(s) allocated from:
      #0 0x7fa404ea9667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
      #1 0x63351c in PyMem_RawMalloc Objects/obmalloc.c:572
      #2 0x63351c in _PyMem_RawWcsdup Objects/obmalloc.c:644
      #3 0x9ab457 in _PyWideStringList_Copy Python/initconfig.c:321
      #4 0x9b48bd in _PyConfig_Copy Python/initconfig.c:857
      #5 0xa20b4c in _PyInterpreterState_SetConfig Python/pystate.c:1834
      #6 0xa07a14 in pycore_create_interpreter Python/pylifecycle.c:554
      #7 0xa07a14 in pyinit_config Python/pylifecycle.c:759
      #8 0xa07a14 in pyinit_core Python/pylifecycle.c:926
      #9 0xa09b17 in Py_InitializeFromConfig Python/pylifecycle.c:1136
      #10 0x4766c2 in pymain_init Modules/main.c:66
      #11 0x47bd12 in pymain_main Modules/main.c:653
      #12 0x47bd12 in Py_BytesMain Modules/main.c:686
      #13 0x7fa404173041 in __libc_start_main (/lib64/libc.so.6+0x27041)

      Indirect leak of 200 byte(s) in 6 object(s) allocated from:
      #0 0x7fa404ea9667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
      #1 0x63351c in PyMem_RawMalloc Objects/obmalloc.c:572
      #2 0x63351c in _PyMem_RawWcsdup Objects/obmalloc.c:644
      #3 0x9ab457 in _PyWideStringList_Copy Python/initconfig.c:321
      #4 0x9b8ee8 in PyConfig_Read Python/initconfig.c:2506
      #5 0xa07282 in pyinit_core Python/pylifecycle.c:920
      #6 0xa09b17 in Py_InitializeFromConfig Python/pylifecycle.c:1136
      #7 0x4766c2 in pymain_init Modules/main.c:66
      #8 0x47bd12 in pymain_main Modules/main.c:653
      #9 0x47bd12 in Py_BytesMain Modules/main.c:686
      #10 0x7fa404173041 in __libc_start_main (/lib64/libc.so.6+0x27041)

      Workaround:

      $ cat Misc/asan-suppression.txt 
      leak:_PyWideStringList_Copy
      $ LSAN_OPTIONS="suppressions=Misc/asan-suppression.txt" make
    2. added
      buildThe build process and cross-build
      performancePerformance or resource usage
      and removed
      buildThe build process and cross-build
      on Jun 12, 2020
    3. vstinner commented on Jun 15, 2020

      @vstinner
      Member

      Regression introduced by commit e81f6e6 in bpo-40910. I wrote PR 20886 to fix it.

    4. changed the title [-]_PyWideStringList_Copy breaks asan builds[/-] [+]PyConfig_Clear() doesn't clear _orig_argv member (_PyWideStringList_Copy breaks asan builds)[/+] on Jun 15, 2020
    5. changed the title [-]_PyWideStringList_Copy breaks asan builds[/-] [+]PyConfig_Clear() doesn't clear _orig_argv member (_PyWideStringList_Copy breaks asan builds)[/+] on Jun 15, 2020
    6. vstinner commented on Jun 15, 2020

      @vstinner
      Member

      New changeset e2d47a0 by Victor Stinner in branch 'master':
      bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
      e2d47a0

    7. tiran commented on Jun 15, 2020

      @tiran
      MemberAuthor

      Works for me, thanks for the quick fix!

    8. miss-islington commented on Jun 15, 2020

      @miss-islington
      Contributor

      New changeset bab0833 by Miss Islington (bot) in branch '3.9':
      bpo-40910: PyConfig_Clear() clears _orig_argv (GH-20886)
      bab0833

    9. vstinner commented on Jun 15, 2020

      @vstinner
      Member

      Works for me, thanks for the quick fix!

      I'm surprised that libasan doesn't allow to run an application which leaks memory :-) I understand that it's the intented behavior. At least in this case, it was a real bug and hopefully it was trivial to fix it!

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of life3.9 (EOL)end of lifebuildThe build process and cross-buildperformancePerformance or resource usage

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions