Skip to content

Bug on multiprocessing.shared_memory.ShareableList #101416

@JunLeecus

Description

@JunLeecus

Hello, I meet some bug when I use multiprocessing.shared_memory.ShareableList.
I want to save image bytes in a ShareableList, but some bytes are dropped. My codes are simple,

import numpy as np
fake_data = np.empty([720, 1280], dtype=np.uint8)
shm_list =  ShareableList([fake_data.tobytes()])
...
def process(image_bytes: bytes):
        data: np.ndarray[np.uint8] = np.frombuffer(image_bytes, np.uint8)
        image = data.reshape((720, 1280))
        shm_list[0] = image_bytes
        print(np.frombuffer(list(shm_list)[0], np.uint8).shape)
        print(np.frombuffer(image_bytes, np.uint8).shape)
...
shm_list.shm.close()
shm_list.shm.unlink()

this with the output
image
it seems some bytes are dropped.

My env

Description:    Ubuntu 20.04.4 LTS
python version : Python 3.8.10

This bug can be reproduce on our 2 Thinkpad X1 PC wirh arch x86_64, but normal on aarch64 device.

Thanks for help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions