Skip to content

Python crashes on large number of client connects to socketserver #95204

Description

@morphex

Crash report

Running the code in this tree:

https://github.com/morphex/smps/tree/59fbc78ebddcc3a68c6ea71200d80683b88b8b7d

Can crash the Python interpreter, with no useful feedback on what's wrong, except that the socketserver must have crashed as connections are refused.

Error messages

Two runs of the smps test; which shows that the number of client connections that crashes Python varies; the first run was after I opened the laptop lid, IIRC:

./test.sh
SMPS running at pid 2941
Starting threads:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
Exception <class 'ConnectionResetError'> (104, 'Connection reset by peer')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionResetError'> (104, 'Connection reset by peer')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Exception <class 'ConnectionResetError'> (104, 'Connection reset by peer')
Exception <class 'ConnectionRefusedError'> (111, 'Connection refused')
Test complete
./test.sh
SMPS running at pid 3048
Starting threads:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
Test complete
morphex@morphex-Latitude-E4310:~/smps$

You can run test.sh with ./test.sh 1000 for example to increase the number of clients generated.

Your environment

Python 3.9.13 (main, May 23 2022, 22:02:02)
[GCC 7.5.0] on linux

Linux morphex-Latitude-E4310 5.4.0-120-generic #136-Ubuntu SMP Fri Jun 10 13:40:48 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal

Package: python3.9-minimal
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 5402
Maintainer: Matthias Klose doko@debian.org
Architecture: amd64
Multi-Arch: allowed
Source: python3.9
Version: 3.9.13-1+bionic1
Depends: libpython3.9-minimal (= 3.9.13-1+bionic1), libexpat1 (>= 2.1~beta3), zlib1g (>= 1:1.2.0)
Pre-Depends: libc6 (>= 2.27)
Recommends: python3.9
Suggests: binfmt-support
Conflicts: binfmt-support (<< 1.1.2)
Description-en: Minimal subset of the Python language (version 3.9)
This package contains the interpreter and some essential modules. It can
be used in the boot process for some basic tasks.
See /usr/share/doc/python3.9-minimal/README.Debian for a list of the modules
contained in this package.
Description-md5: cd370bbd0ff51beae7a757794c49c53c
Cnf-Visible-Pkgname: python3.9

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Jul 24, 2022
  2. jepler commented on Jul 24, 2022

    @jepler
    Contributor

    From what I could see, in your protocol sending the QUIT request on the client causes the whole server to shut down:

                    if input.lower().strip() == "quit":
                       DEBUG_PRINT("Exiting")                                     
                       self.server.shutdown()
    

    and in def _run_client_test(): you have client.quit().

  3. morphex commented on Jul 24, 2022

    @morphex
    Author

    Ah, of course. Thanks. :)

  4. added
    type-bugAn unexpected behavior, bug, or error
    and removed
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Jul 25, 2022
  5. terryjreedy commented on Jul 25, 2022

    @terryjreedy
    Member

    For future reference, the label 'crash' means a hard exit, as with stack overflow. You gave no indication that you say such. Python exceptions are at most a bug. I changed the label for the benefit of anyone searching for true crashes.

    Similarly for changing the close reason, which is confusing if one does not know about the drop menu.

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-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions