Skip to content

High CPU usage when sending data to broken socket connection on Linux #1018

@mumez

Description

@mumez

Description

The VM shows extremely high CPU usage when data is sent to a socket and the client connection is destroyed. This issue is specific to Linux VM and does not occur on Windows.

Key characteristics:

  • High CPU usage starts immediately when there is data sent but not received AND the client socket is closed
  • The order of close/send operations doesn't matter
  • Issue is Linux-specific (not reproducible on Windows VM)
  • This is a regression - the issue did not occur with VM version 10.0.5
  • Confirmed to occur with VM versions 10.3.6 and later

Code to Reproduce

Minimal reproduction case:

server := Socket newTCP listenOn: 12345 backlogSize: 5.
[client := Socket newTCP connectTo: NetNameResolver localHostAddress port: 12345] fork.
server waitForConnectionFor: 30.
accepted := server accept.
accepted inspect. "OK"

"The following order is irrelevant if these are both done"
accepted sendData: (String new: 1 withAll: $a). 
client destroy. 

Target VM

  • Platform: Linux
  • Affected versions: 10.3.6 and later
  • Working version: 10.0.5
  • Not affected: Windows VM

Expected Behavior

The VM should handle broken socket connections gracefully without consuming excessive CPU resources, similar to the behavior in VM version 10.0.5 and current Windows VM behavior.

Actual Behavior

Extremely high CPU usage when attempting to send data to a broken socket connection

Additional Context

This issue simulates real-world scenarios where socket connections are unexpectedly broken (e.g., web browser closing unexpectedly). The regression between VM versions 10.0.5 and 10.3.6 suggests this was introduced by changes in socket handling.

Split from the issue:
#939

Screenshot

Image

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