Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BUG] 100% CPU due to busy-polling bug #11473

@marcelstoer

Description

@marcelstoer

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Just starting Claude Code will make it consume 100% CPU.

What Should Happen?

When it's idle, it shouldn't use a significant number of CPU cycles.

Error Messages/Logs

Steps to Reproduce

  1. Start Claude
  2. Monitor CPU usage

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.0.37

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

I ran sudo dtruss -p <claude-pid> | tail -n 20 to see what it's doing. It appears to be a classic busy-polling bug in the event loop.

recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x6, 0x0, 0x0)		 = 1 0
recvfrom(0x27, 0x7F9E48078020, 0x80000)		 = -1 Err#35
kevent64(0x0, 0x0, 0x0)		 = 1 0

Or this

recvfrom(0x13, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x2B, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x2A, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x28, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x2D, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x24, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x1C, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x1B, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x22, 0x7FC6700A8020, 0x80000) = -1 Err#35
recvfrom(0x2C, 0x7FC6700A8020, 0x80000) = -1 Err#35

The process is continuously calling recvfrom() on multiple sockets (file descriptors 0x13, 0x2B, etc.), getting 'no data yet', and immediately trying again — in a tight loop with no sleep.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas reproHas detailed reproduction stepsperf:memoryplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions