python / cpython

The Python programming language
https://www.python.org
Other
63.41k stars 30.37k forks source link

NNTPLib connections become corrupt after long periods of activity #65667

Closed 56379c18-a76c-440d-adea-be88477daa40 closed 2 years ago

56379c18-a76c-440d-adea-be88477daa40 commented 10 years ago
BPO 21468
Nosy @pitrou, @jwilk, @bitdancer, @vadmium

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['library'] title = 'NNTPLib connections become corrupt after long periods of activity' updated_at = user = 'https://bugs.python.org/JamesMeneghello' ``` bugs.python.org fields: ```python activity = actor = 'martin.panter' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'James.Meneghello' dependencies = [] files = [] hgrepos = [] issue_num = 21468 keywords = [] message_count = 4.0 messages = ['218223', '219193', '219211', '226527'] nosy_count = 5.0 nosy_names = ['pitrou', 'jwilk', 'r.david.murray', 'martin.panter', 'James.Meneghello'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue21468' versions = ['Python 3.2', 'Python 3.3', 'Python 3.4'] ```

56379c18-a76c-440d-adea-be88477daa40 commented 10 years ago

After establishing an NNTP connection for a long-running process (up to hours at a time), the connection will eventually die and start producing infinite random garbage output, a small part of which is seen below. Any subsequent calls to the connection will produce a random stream of exceptions and data, as the library flips out. This happens with the connection being constantly used over the time period.

The problem occurs approximately 2 hours after the initial connection is established, and happens after approximately the same amount of time each run. The below connection was initialised at 22:03:27 and broke at 23:55:58.

Workaround is pretty simple: kill the connection and reinitialise it. Calling quit() will fail, however, with a series of random exceptions produced, because quit() attempts to send a QUIT command to the broken socket.

Tested on Ubuntu 13.10 (which fails) and Windows 8.1, which does not appear to have the same problem - I'm unable to replicate it on Win8.1.

--

2014-05-10 23:55:58,937 - ERROR - nntp error: <ɀ\udcd9?\udc95\udcf6Mo\udcdd0\udcb9\udcb9P0/)\udce4\udcbeBo\udc90q\udcb52\udc97\udcd7\udcf7f\udcacŸ\udcfa< \udceaO2cC\udc92V\udcc1\udcc1ذ\ud,\udcdd\udcf1(\udc82>\udcbb\udc906Z4Ft<\udceeD\udcb5\udc9d\udcba\udcb5\udca8\udccaEk\udcfa\udcb6\udcc8\udcc1\udcf4yԫ\udce6\udccf\udcd8\udcc9_\udcf9c$\udc8cc֟cB\udca9\udceefudcecsr<Cw+4\udc973\udce8\udceem\udc93\udcb4\udca1\udcd4\udc9f\udcb4\udcf1G\udcc1XI\udc9c\udcbc~\udcacK\udcbe\udc98\udcee־]I8\udc9f\udcac\udcc7\udcc6a\udcf58\udcdc-\udc93\udc82\udca6\udc90\udcf0\udcb5\udcf2\udcbeA?\udcf0\udc99:\udcb1\udc9e[\udcf9\udcfa`fvudcad\udcfa\udce7 -f\udcf8\udc81$٫\udc8bH>\udcc1\udced�{\udc90\udca1\udcb2\udc81\udce0I\udc91\udcfeD\udceeE\udcd3\udcf6$\udccfbd\udcec"]\udcb0\udc9a\udc8cf6\udcfa\udcbf\udcea\udcb3h:S\udcbc\udc8dG\udca6t\udc85\udcc6(\udcf2\udce0Kb\udcbe\udcb8j\udc94\udc85B-\udc9dL+le\udcad/.\udc87\udcbbtv\udc89!\udc8f/\udcf9_\udce0 \udcad\udc98\udcc0\udcc40T\udcc21\udcd3\udcebȳ \udcbc@\udcf5mG\udcba\udca0\udcc2]۲LUخ\udcc0\udcc*\udce1,H6\udcccja\udcf9h\udc97f\udc95\udc9c\udce3\udc88%\udca7\udc860\udcfb\udc83\udca2\udca1\udccfH\udcd3Uxߴ\udce2\udc86өY\udcad\udcbb\udcd7\udcf7\udca7W㌘\udcf6\udcbf\udce9AI1P\udc8d\udc959^\udcc5\udcc3n\udce5xY\udcfb\udc87\udcfdp\udcb4nT\udca9\udc97\udcfbp\udc8aTkkb\udc90C\udcaa\udc8aq\udcddUm\udcd5sJsS7l\udcdb`\udc88hU\udcf6

bitdancer commented 10 years ago

This is likely to be hard to reproduce (but perhaps someone will try). The best hope of getting it fixed is probably for you to investigate it yourself.

Were you using ssl? Also, have you tried all the python versions you selected, and if so, which exact versions?

56379c18-a76c-440d-adea-be88477daa40 commented 10 years ago

Yeah, I didn't have a lot of time so I chose just to work around it. When I get a chance I'll have a better look.

Good point: I didn't think to try it with SSL off (SSL is enabled for all connections by default with this application). I'll test this and see if it still breaks.

I tested it with 3.2.5, 3.3.2, 3.4.0a (was the latest at the time) on Ubuntu 64-bit. As said, didn't encounter the same problems with those versions on Windows 8 64-bit.

vadmium commented 10 years ago

Perhaps this is similar to bpo-22350 which I just raised. Whenever the NNTP context manager exits, a QUIT command is called, and if the context manager is exiting due to a protocol error or some other exception not handled by the protocol, the code will try and read other protocol data as the QUIT response.

Perhaps your code was interrupted in the middle of reading a yEnc binary body and that is why it looks like garbage?

hugovk commented 2 years ago

Let's close this old issue because the nntplib module is deprecated in 3.11 and set for removal in 3.13.

See PEP 594 – Removing dead batteries from the standard library and https://github.com/python/cpython/issues/91217.

AlexWaygood commented 2 years ago

Let's close this old issue because the nntplib module is deprecated in 3.11 and set for removal in 3.13.

See PEP 594 – Removing dead batteries from the standard library and #91217.

Cc. @jwilk, @bitdancer, @vadmium