Opened 16 months ago

Last modified 16 months ago

#18529 new bug

WebSocket thread sometimes pegging a core on GitHub

Reported by: humdinger Owned by: pulkomandy
Priority: normal Milestone: Unscheduled
Component: Kits/Web Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

This is on HaikuWebKit 1.9.6, WebKit 616.1.22

Sometimes when going to a GitHub repo a "WebSocket thread" pegs a CPU core. Unfortunately, it's not relyably reproducible (or 'luckily', when you actually want to use the site without the CPU fan blasting...).

I did save a debug report of the pegging "WebSocket thread" (attached), if that is of any help. It starts with:

thread 6923: WebSocket thread 
state: Debugged

Frame		IP			Function Name
-----------------------------------------------
00000000	0x1735b53a78a	_kern_poll + 0xa 
	Disassembly:
		_kern_poll:
		0x000001735b53a780:           4989ca  mov %rcx, %r10
		0x000001735b53a783:   48c7c080000000  mov $0x80, %rax
		0x000001735b53a78a:             0f05  syscall  <--

0x7f57519b90d0	0x1735b543af5	poll + 0x15 
0x7f57519b9110	0x1bf2a130eaf	BAbstractSocket::_WaitFor(int, long) const + 0x6f 
0x7f57519b9230	0x12e4629eac7	WebCore::SocketStreamHandleImpl::threadEntryPoint() + 0x1a7 
0x7f57519b9260	0x12e482a89fc	WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) + 0x5c 
0x7f57519b9270	0x12e48314784	_ZN3WTFL19wtfThreadEntryPointEPv + 0x4 
0x7f57519b9290	0x1735b549155	pthread_thread_entry(void*, void*) + 0x15 
00000000	0x7f1737b48258	commpage_thread_exit + 0 

Attachments (2)

WebPositive-2163-debug-27-07-2023-07-05-31.report (53.0 KB ) - added by humdinger 16 months ago.
strace.txt (455.3 KB ) - added by humdinger 16 months ago.
strace -T output

Download all attachments as: .zip

Change History (9)

comment:1 by waddlesplash, 16 months ago

If you can manage to reproduce this again, could you run an strace -T <pid> in Terminal, with the PID of the looping WebPositive process?

comment:2 by waddlesplash, 16 months ago

(Only a second or so of output will be necessary.)

comment:3 by humdinger, 16 months ago

That only says:

strace: Failed to install team debugger: Operation on invalid team

The <pid> is the ID of the thread as shown in Slayer or Debugger when debugging that pegging thread, right?

comment:4 by pulkomandy, 16 months ago

Result: a lot of calls to poll() on fd 33, returning POLLIN|POLLERR revents.

poll([{fd=33, events=POLLIN}], 0x1, 0x4e20, (nil)) = 0x1 ([{fd=33, revents=POLLIN|POLLERR}])

comment:5 by humdinger, 16 months ago

Aha the <pid> is the team ID of WebPositive, not the pegging thread ID. I've attached a short strace capture.

by humdinger, 16 months ago

Attachment: strace.txt added

strace -T output

comment:6 by waddlesplash, 16 months ago

I guess this method is called from WaitForReadable. Where will the socket error be detected and cleared? Because if it isn't, then this will indeed just loop forever.

comment:7 by waddlesplash, 16 months ago

The logic in WebKit is here: https://github.com/haiku/haikuwebkit/blob/haiku/Source/WebKitLegacy/haiku/WebCoreSupport/SocketStreamHandleHaiku.cpp#L128

Since this is a Haiku-specific implementation, maybe there's some mechanism for detecting when we are supposed to terminate the loop which this missed in the WebKit upgrades?

Note: See TracTickets for help on using tickets.