Skip to content

Correct use of GetCurrentMessageLoopThreadId is racy #2

@cfergeau

Description

@cfergeau

GetCurrentMessageLoopThreadId documentation says:

//  Returns [...] "0" if [a message loop] is not running. The latter indicates a mistake, 
// as this function should only be called after a call to one of the _OnQuit functions.

The _OnQuit functions create the message loop in a go routine (see

func initLoop() {
loopInit.Do(func() {
go messageLoop()
})
}
), so when these functions return, it's not 100% guaranteed that a message loop is running and that it has a thread id.

We hit that race in gvisor-tap-vsock with test failures when running in a gh actions runner: containers/gvisor-tap-vsock#433

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