Skip to content

Integer overflow in TCP comm #4538

Closed

Description

@fjetter

What happened:

I am receiving integer overflow errors in some large scale computations. Haven't had the chance to construct a MCVE but will try to.

cc @jakirkham I believe you reworked this section recently. Maybe you spot what's going wrong right away

What you expected to happen:

Minimal Complete Verifiable Example:

N/A

Anything else we need to know?:

Traceback (most recent call last):
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/distributed/core.py", line 554, in handle_stream
    msgs = await comm.read()
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/distributed/comm/tcp.py", line 199, in read
    n = await stream.read_into(frames)
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/tornado/iostream.py", line 475, in read_into
    self._try_inline_read()
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/tornado/iostream.py", line 842, in _try_inline_read
    pos = self._read_to_buffer_loop()
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/tornado/iostream.py", line 755, in _read_to_buffer_loop
    if self._read_to_buffer() == 0:
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/tornado/iostream.py", line 867, in _read_to_buffer
    bytes_read = self.read_from_fd(buf)
  File "/mnt/mesos/sandbox/venv/lib/python3.6/site-packages/tornado/iostream.py", line 1592, in read_from_fd
    return self.socket.recv_into(buf, len(buf))
  File "/usr/lib/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
OverflowError: signed integer is greater than maximum (distributed.core)

Environment:

  • Dask version: dask/dask@91cee5b
  • tornado version: 6.1
  • Python version: py3.6
  • Operating System: Deb9
  • Install method (conda, pip, source): pip

Activity

  1. fjetter commented on Feb 23, 2021

    @fjetter
    MemberAuthor

    might've been introduced by #4506

  2. jakirkham commented on Feb 23, 2021

    @jakirkham
    Member

    Have we confirmed it is due to that change? Does the previous commit work?

  3. fjetter commented on Feb 23, 2021

    @fjetter
    MemberAuthor

    I reverted the commit and didn't run into the issue anymore but I'm also not sure if my computation triggers this reliably.

  4. jakirkham commented on Feb 23, 2021

    @jakirkham
    Member

    Ok thanks for that data point

    It might be worth sticking a print(frames_nbytes) in read to see how large the message is when things fail

  5. jakirkham commented on Feb 23, 2021

    @jakirkham
    Member

    Does this show up in other Python versions?

  6. jakirkham commented on Feb 23, 2021

    @jakirkham
    Member

    Asking about other Python versions as 3.6 is the only one with SSLObject. It got removed with PR ( python/cpython#5252 ) in 3.8, which was also backported to 3.7. So would be good to know if this is just an oddity of 3.6

  7. jakirkham commented on Feb 24, 2021

    @jakirkham
    Member

    Does this show up in other Python versions?

    Just checking in here. @fjetter do you have insight into this question?

  8. fjetter commented on Feb 25, 2021

    @fjetter
    MemberAuthor

    As of now, I don't have any more insights. I will try to set up another test run today to see if I can reproduce it another time. I will also try another python version. Since this requires a bit of time on my end, is there anything else worth checking out in these test runs?

    • print statement for the frames_nbytes
    • python version
      anything else worthy logging/inspecting?
  9. fjetter commented on Feb 25, 2021

    @fjetter
    MemberAuthor

    So far, I was not able to reproduce :/

  10. jakirkham commented on Feb 25, 2021

    @jakirkham
    Member

    Interesting. What things have been tried thus far?

    Yeah those are the main things I can think of. Are there other things that you think would be relevant to test?

  11. jrbourbeau commented on Mar 3, 2021

    @jrbourbeau
    Member

    Just checking in here, @fjetter any luck on reproducing? I don't mean to apply unneeded pressure, but I'm wondering if this is a blocker for our upcoming release (xref dask/community#129)

  12. fjetter commented on Mar 4, 2021

    @fjetter
    MemberAuthor

    I'm not actively working on this due to limited time and my last efforts reproducing it was not successful. Considering that the exception is caused by a SSLObject which only exists in py3.6, I'm wondering if it is a reasonable assumption that this will only be an issue on py36?
    My gut feeling tells me that a very difficult to reproduce, yet to be confirmed issue which likely only triggers on a python version we're about to drop should not block a release.

  13. jakirkham commented on Mar 18, 2021

    @jakirkham
    Member

    Should we go ahead and close now that Python 3.6 is dropped?

  14. jrbourbeau commented on Mar 18, 2021

    @jrbourbeau
    Member

    Yeah, let's close for now and re-open is needed

  15. 2 remaining items

  16. jakirkham commented on May 21, 2021

    @jakirkham
    Member

    Do you have a reproducer? If so, can you please share this in a new issue?

  17. RichardScottOZ commented on May 21, 2021

    @RichardScottOZ

    Not easy to reproduce in that is large scale satellite data processing via Open Data Cube on a Dask Gateway Kubernetes cluster, but can give some details.

  18. quasiben commented on May 21, 2021

    @quasiben
    Member
  19. jakirkham commented on Jun 2, 2021

    @jakirkham
    Member

    At the end of that Python issue Christian notes this is fixed in Python 3.10. PR ( python/cpython#25468 ) seems to be the relevant change.

    Also he notes that this due to limitations of OpenSSL 1.0.2 and so remains an issue where that OpenSSL version is used. This is not an issue when OpenSSL 1.1.1 is used with the patch noted above

    Edit: Asked on the issue whether it would be possible to backport the fix (note this would still require package builders to use the newer OpenSSL)

  20. RichardScottOZ commented on Jun 2, 2021

    @RichardScottOZ

    Seems to happen on the bigger/longer workloads I was doing- haven't seen it on small ones as yet.

  21. jakirkham commented on Jun 3, 2021

    @jakirkham
    Member

    Yeah suspect that it is likely reproducible with a large message if that CPython bug is relevant. If not, maybe we are missing something

  22. jakirkham commented on Jul 24, 2021

    @jakirkham
    Member

    Thinking about this a bit more, one option would be to take smaller views of the buffer we are reading into and fill those. We can ensure these buffers are big enough for OpenSSL to handle, but no bigger. After looking at the CPython code and OpenSSL, this appears to be the maximum value of a C int, which will be implementation dependent. Have written some code in PR ( #5115 ), which should workaround this issue in this way. If anyone can reproduce, would be good to have some feedback on whether that works.

  23. mrocklin commented on Jul 26, 2021

    @mrocklin
    Member

    Should we be adjusting our maximum shard size in comms under certain conditions? We already reduce this for different systems. For example in websockets we restrict things today to 8MiB frames. Maybe we should do the same for TLS under certain versions

  24. jakirkham commented on Jul 26, 2021

    @jakirkham
    Member

    It's possible we will want to change the frame size if we discover this batching of smaller amounts of data through OpenSSL is causing us performance issues. That said, I haven't dived into that side of things.

    On a different note, it's interesting that OpenSSL uses an int here at all instead of size_t, which is what OpenSSL 1.1.1+ does and is what one would use in C typically. Maybe this code is quite old and precedes size_t or they would have been nearly equivalent at the time? Or no one thought so much data would be given to OpenSSL? Or perhaps whatever algorithm was used couldn't handle size_t amounts of data previously?

  25. jakirkham commented on Jul 28, 2021

    @jakirkham
    Member

    As this error could show up in the write code path as well, added PR ( #5134 ) to protect against that too.

    Edit: Superseded by PR ( #5141 )

  26. jakirkham commented on Jul 30, 2021

    @jakirkham
    Member

    We are cutting a release tomorrow. These fixes should be in there ( dask/community#173 )

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