Skip to content

cloudpickle can produce incorrect pickles #129

Description

@pitrou
>>> import multiprocessing as mp, cloudpickle, pickletools
>>> v = mp.Value('i')
>>> cloudpickle.dumps(v)
b'\x80\x02'
>>> import pickletools
>>> pickletools.dis(cloudpickle.dumps(v))
    0: \x80 PROTO      2
Traceback (most recent call last):
  File "<ipython-input-28-9e637ba398b4>", line 1, in <module>
    pickletools.dis(cloudpickle.dumps(v))
  File "/home/antoine/miniconda3/envs/dask36/lib/python3.6/pickletools.py", line 2398, in dis
    for opcode, arg, pos in genops(pickle):
  File "/home/antoine/miniconda3/envs/dask36/lib/python3.6/pickletools.py", line 2238, in _genops
    raise ValueError("pickle exhausted before seeing STOP")
ValueError: pickle exhausted before seeing STOP

Activity

  1. adamklein commented on Dec 13, 2017

    @adamklein

    I've run into this as well.

    The problem is runtime exceptions can be swallowed here:
    https://github.com/cloudpipe/cloudpickle/blob/master/cloudpickle/cloudpickle.py#L269
    in my case, it turned out it was a changing dictionary while cloudpickle iterated through it; in @pitrou's example, it's RuntimeError: Synchronized objects should only be shared between processes through inheritance Should the except block end with a raise instead?

  2. pitrou commented on Dec 13, 2017

    @pitrou
    MemberAuthor

    Thanks for diagnosing this. It should be pretty easy to fix.

  3. added a commit that references this issue on Dec 13, 2017
    a62d920
  4. added a commit that references this issue on Feb 6, 2018
    3c2e52c
  5. added a commit that references this issue on Feb 6, 2018
    1105da1
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions