Skip to content

Regression in msgpack-python 1.0.0 wraps around timestamps after 2038 #451

Closed

Description

@progval

Hi,

I just found this data corruption after upgrading msgpack from 1.0.0 to 1.0.1:

$ pip3 install --user msgpack==1.0.0
[...]
$ python3 -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
2100-01-01 01:01:00+00:00
$ pip3 install --user msgpack==1.0.1
[...]
$ python3 -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
1963-11-25 18:32:44+00:00

Activity

  1. methane commented on Dec 17, 2020

    @methane
    Member

    On my mac:

    $ python3 -m venv venv
    $ source venv/bin/activate
    
    $ pip install msgpack==1.0.0
    ...
    Successfully installed msgpack-1.0.0
    
    $ python -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
    2100-01-01 01:01:00+00:00
    
    $ pip install msgpack==1.0.1
    ...
    Successfully installed msgpack-1.0.1
    
    $ python -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
    2100-01-01 01:01:00+00:00
    

    What is your enviornment? Do you use speedup module?

  2. progval commented on Dec 17, 2020

    @progval
    Author

    I'm on Debian 10, python 3.7.3. msgpack was installed from this wheel: https://files.pythonhosted.org/packages/8e/e8/a4b64266a1fb99190a3a03c999395108ef2fde5d912343b2a6cf435d59af/msgpack-1.0.1-cp37-cp37m-manylinux2010_x86_64.whl

    I don't know about the speedup module, but I can see this:

    >>> msgpack._cmsgpack
    <module 'msgpack._cmsgpack' from '/home/tmp/venv/lib/python3.7/site-packages/msgpack/_cmsgpack.cpython-37m-x86_64-linux-gnu.so'>
    
  3. jfolz commented on Dec 17, 2020

    @jfolz
    Contributor

    Can confirm the issue with Python 3.6 through 3.9 in the manylinux 2014 docker container:

    $ sudo docker run --rm -it quay.io/pypa/manylinux2014_x86_64
    [root@56d0702a09b2 /]# /opt/python/cp37-cp37m/bin/pip install msgpack==1.0.0
    ...
    Successfully installed msgpack-1.0.0
    [root@56d0702a09b2 /]# /opt/python/cp37-cp37m/bin/python -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
    2100-01-01 01:01:00+00:00
    [root@56d0702a09b2 /]# /opt/python/cp37-cp37m/bin/pip install msgpack==1.0.1
    ...
    Successfully installed msgpack-1.0.1
    [root@56d0702a09b2 /]# /opt/python/cp37-cp37m/bin/python -c "import msgpack, datetime; print(msgpack.unpackb(msgpack.packb(datetime.datetime(2100, 1, 1, 1, 1, tzinfo=datetime.timezone.utc), datetime=True), timestamp=3))"
    1963-11-25 18:32:44+00:00
    [root@56d0702a09b2 /]#
    

    So it seems the linux build specifically casts to int32 somewhere.

  4. added a commit that references this issue on Dec 18, 2020
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions