Skip to content

ShareableList cannot safely handle multibyte utf-8 characters #88336

Closed

Description

@huwcbjones
BPO 44170
Nosy @akulakov, @huwcbjones
PRs
  • gh-88336: Fix UnicodeDecodeError with multibyte utf8 characters in ShareableList #26328
  • Files
  • shareablelist_mwe.py: Minimum working example to trigger observed behaviour
  • 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 = None
    created_at = <Date 2021-05-18.11:12:09.372>
    labels = ['3.8', 'type-bug', 'library']
    title = 'ShareableList cannot safely handle multibyte utf-8 characters'
    updated_at = <Date 2021-12-09.06:21:18.650>
    user = 'https://github.com/huwcbjones'

    bugs.python.org fields:

    activity = <Date 2021-12-09.06:21:18.650>
    actor = 'andrei.avk'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-05-18.11:12:09.372>
    creator = 'huwcbjones'
    dependencies = []
    files = ['50049']
    hgrepos = []
    issue_num = 44170
    keywords = ['patch']
    message_count = 4.0
    messages = ['393868', '393869', '408074', '408075']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'andrei.avk', 'huwcbjones']
    pr_nums = ['26328']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44170'
    versions = ['Python 3.8']

    Linked PRs

    Activity

    1. huwcbjones commented on May 18, 2021

      huwcbjonesmannequin
      MannequinAuthor

      I've experienced a UnicodeDecodeError when adding unicode strings that contain multibye utf-8 characters into a shareable list.
      My observation is that ShareableList chunks the list of strings before sending it over the process boundary, however this chunking process is not multibyte aware and will chunk in the middle of multibyte characters.
      On the other end, this results in the ShareableList throwing a UnicodeDecodeError when it fails to decode not-a-full multibyte utf-8 character.

      From running the attached MWE, I see that the string is sent in two chunks, the first being b'Boom \xf0\x9f\x92\xa5 \xf0\x9f\x92\xa5 \xf0' which clearly splits the 4 bytes of the 💥 character into the first byte and remaining 3 bytes.

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      stdlibStandard Library Python modules in the Lib/ directory
      on May 18, 2021
    3. huwcbjones commented on May 18, 2021

      huwcbjonesmannequin
      MannequinAuthor

      The workaround I am using is to manually encode/decode.

      For the MWE, this means encoding on the creation side

      shared_list = smm.ShareableList([s.encode() for s in strings])
      

      and decoding before using the string

      for enc_str in shared_list:
         string = enc_str.decode()
      
    4. akulakov commented on Dec 9, 2021

      @akulakov
      Contributor

      We classify 'crash' type as seg faults etc, so changing this to 'behavior' type.

    5. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Dec 9, 2021
    6. akulakov commented on Dec 9, 2021

      @akulakov
      Contributor

      I've confirmed this issue is still present in 3.11.

    7. transferred this issue fromon Apr 10, 2022
    8. added
      3.13only security fixes
      3.14bugs and security fixes
      3.15bugs and security fixes
      3.16new features, bugs and security fixes
      and removed on Aug 14, 2026
    9. added 3 commits that reference this issue on Nov 1, 2026
    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.13only security fixes3.14bugs and security fixes3.15bugs and security fixes3.16new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions