This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pierreglaser
Recipients bjs, davin, mental, pierreglaser, pitrou
Date 2019-07-26.11:23:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1564140227.15.0.734284387477.issue37652@roundup.psfhosted.org>
In-reply-to
Content
The root of the error is that struct.pack_into starts by memsetting the underlying memory area with NULL bytes before filling the data with memcpy. If ShareableList._get_packing_format is called between the two operations (through a concurrent __getitem__ call from another process), struct.unpack_from will return an empty tuple which is the direct cause of the error you're seeing.

In the general case though, memcpy is not atomic so even without the memset call before, results of struct.unpack_from may be invalid in a concurrent setting.

shared_memory is a low level python module. Precautions should be made when handling concurrently the shared_memory objects using synchronization primitives for example. I'm not sure this should be done internally in the SharedMemory class -- especially, we don't want to slow down concurrent READ access. +1 For a documentation addition.
History
Date User Action Args
2019-07-26 11:23:47pierreglasersetrecipients: + pierreglaser, pitrou, davin, bjs, mental
2019-07-26 11:23:47pierreglasersetmessageid: <1564140227.15.0.734284387477.issue37652@roundup.psfhosted.org>
2019-07-26 11:23:47pierreglaserlinkissue37652 messages
2019-07-26 11:23:46pierreglasercreate