opensmalltalk-vm icon indicating copy to clipboard operation
opensmalltalk-vm copied to clipboard

Problems with Linux VM - EPOLL

Open dtlewis290 opened this issue 3 years ago • 2 comments

Reported on vm-dev mailing list: http://lists.squeakfoundation.org/pipermail/vm-dev/2022-February/037652.html

Hi Levente and All,

Just wanted to pass on some information about EPOLL and Linux.

We were working on sharing our applications through RFB but were having an issue where keyboard input created a change on the remote window but the changes were not showing up. You could see the issue with a simple browser doing a web search on google and pressing enter. The screen froze but if you clicked with a mouse or created any other event the changes showed up. Eliot suggested the issue could be with EPOLL not signaling the semaphore properly when data was available on the socket. After Eliot created a new EPOLL-less linux vm the problems went away. There does appear to be an issue with EPOLL on linux.

All the best,

Ron Teitelbaum

dtlewis290 avatar Feb 21 '22 22:02 dtlewis290

EPOLL on Linux can be a bit problematic when fork() is used (OSProcess forkSqueak). I wonder if there may also be some issues related to EPOLL on Linux pthreads? Totally guessing but Linux threads are built on top of its process model so it makes me wonder.

Here are some updates I've made in the last year related to EPOLL on Linux when fork() may be involved:

Author: David T Lewis [email protected] Date: Fri Jul 23 18:47:02 2021 -0400 Merge pull request #552 from OpenSmalltalk/dtl/epoll-forksqueak For epoll aio, close and reopen the epoll fd in forked child process

commit 066a43128584d55964f4a6ace4b2c878cf96087e Author: David T. Lewis [email protected] Date: Mon Feb 8 15:14:42 2021 -0500 For epoll aio, close and reopen the epoll fd in forked child process Factor the epoll initiation out of aioInit into new epollInit function and invoke it via pthread_atfork in the child process after a fork. Prevents misdelivery of events from the common kernel epoll structures.

commit f376ffbc0b6d62047b7effb7f29d405fbd7e4611 Author: David T. Lewis [email protected] Date: Sun Feb 7 23:16:24 2021 -0500 Fix epoll event delivery error messages cut and paste error

commit b6616b21d263ecaa334d458bf3a9579fcb88c635 Author: David T. Lewis [email protected] Date: Sun Feb 7 12:12:42 2021 -0500 Handle epoll event delivery errors without VM segfault. Under certain error conditions epoll may deliver event notification to the wrong process, with empty event data provided by the kernel. If this happens, handle the condition with a message to stderr and proceed without segfault. Error messages will look like this:

  aioPoll in process 9055 no readHandler in epollEventData undefined handler called (fd 0, flags 2)

commit 75498075b2bd030794f54c5303d00626fe33b195 Author: David T. Lewis [email protected] Date: Sun Feb 7 12:09:51 2021 -0500 Rearrange forgetXDisplay to disable aio before fd close. Required for epoll event handling, we should not close the descriptor before unregistering it.

dtlewis290 avatar Feb 21 '22 23:02 dtlewis290

Maybe thats a got tipping point switching to libuv?

krono avatar Feb 22 '22 09:02 krono