New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: OpenBSD: TestFifoEOF hangs #25877

Open
ianlancetaylor opened this Issue Jun 13, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ianlancetaylor
Contributor

ianlancetaylor commented Jun 13, 2018

On amd64 OpenBSD 6.2, the new os test TestFifoEOF simply hangs until the overall test times out. I don't know why. It seems to be true whether or not we poll on fifos, so it seems like a basic fifo problem.
I'm going to skip the test on OpenBSD.

@nmeum

This comment has been minimized.

nmeum commented Oct 1, 2018

I am currently writing a go program which makes heavy use of named pipes and works fine on Linux as is. Unfortunately, it hangs on OpenBSD 6.3 (amd64) with go 1.10 and I believe that this is due to this bug.

A minimal example to reproduce the hang I am experiencing is:

package main

import (
        "fmt"
        "os"
)

func main() {
        go func() {
                fmt.Println("writer: os.OpenFile")
                w, err := os.OpenFile("myfifo", os.O_WRONLY, 0)
                if err != nil {
                        panic(err)
                }
                fmt.Println("writer: os.OpenFile done")
                w.Close()
        }()

        fmt.Println("reader: os.OpenFile")
        r, err := os.OpenFile("myfifo", os.O_RDONLY, 0)
        if err != nil {
                panic(err)
        }
        fmt.Println("reader: os.OpenFile done")
        r.Close()
}

Run as:

$ mkfifo myfifo
$ go run test.go
reader: os.OpenFile
writer: os.OpenFile


So both threads hang while attempting to open the named pipe. ktrace(1) reveals that both never return from the open syscall which likely explains why it doesn't matter "whether or not we poll on fifos":

 <…>
 45296 fifotest GIO   fd 1 wrote 20 bytes
       "reader: os.OpenFile
       "
 45296 fifotest RET   write 20/0x14
 45296 fifotest CALL  open(0xc420014120,0x10000<O_RDONLY|O_CLOEXEC>)
 45296 fifotest NAMI  "myfifo"
 45296 fifotest RET   nanosleep 0
 45296 fifotest CALL  clock_gettime(CLOCK_MONOTONIC,0xc420041f08)
 45296 fifotest STRU  struct timespec { 1761091.403056708 }
 45296 fifotest RET   clock_gettime 0
 45296 fifotest CALL  nanosleep(0xc420041f08,0)
 45296 fifotest STRU  struct timespec { 0.000020000 }
 45296 fifotest RET   nanosleep 0
 45296 fifotest CALL  clock_gettime(CLOCK_MONOTONIC,0xc420041f08)
 45296 fifotest STRU  struct timespec { 1761091.423613458 }
 45296 fifotest RET   clock_gettime 0
 45296 fifotest CALL  __thrwakeup(0xc4200327b8,1)
 45296 fifotest RET   __thrwakeup 0
 45296 fifotest CALL  nanosleep(0xc420041f08,0)
 45296 fifotest STRU  struct timespec { 0.000020000 }
 45296 fifotest RET   __thrsleep 0
 45296 fifotest CALL  write(1,0xc420012160,0x14)
 45296 fifotest GIO   fd 1 wrote 20 bytes
       "writer: os.OpenFile
       "
 45296 fifotest RET   write 20/0x14
 45296 fifotest CALL  open(0xc420014127,0x10001<O_WRONLY|O_CLOEXEC>)
 45296 fifotest RET   nanosleep 0
 45296 fifotest CALL  clock_gettime(CLOCK_MONOTONIC,0xc420041f08)
 45296 fifotest STRU  struct timespec { 1761091.444142068 }
 45296 fifotest RET   clock_gettime 0
 45296 fifotest CALL  nanosleep(0xc420041f08,0)
 45296 fifotest STRU  struct timespec { 0.000020000 }
 45296 fifotest RET   nanosleep 0
 45296 fifotest CALL  clock_gettime(CLOCK_MONOTONIC,0xc420041f08)
 45296 fifotest STRU  struct timespec { 1761091.464243148 }
 45296 fifotest RET   clock_gettime 0
 45296 fifotest CALL  sigprocmask(SIG_SETMASK,~0<>)
 45296 fifotest RET   sigprocmask 0<>
 45296 fifotest CALL  __tfork(0xc420041de8,24)
 45296 fifotest STRU  struct __tfork { tcb=0xc420032888, tid=0xc420032848, stack=0xc420040000 }
 45296 fifotest RET   __tfork 445493/0x6cc35
 45296 fifotest CALL  sigprocmask(SIG_SETMASK,0<>)
 45296 fifotest RET   sigprocmask ~0x10100<SIGKILL|SIGSTOP>
 45296 fifotest CALL  nanosleep(0xc420041f08,0)
 45296 fifotest STRU  struct timespec { 0.000020000 }
 45296 fifotest RET   __tfork 0
 45296 fifotest CALL  __set_tcb(0xc420032890)
 45296 fifotest RET   __set_tcb 0
 45296 fifotest CALL  sigaltstack(0,0xc42003ff60)
 45296 fifotest RET   sigaltstack 0
 45296 fifotest CALL  sigaltstack(0xc42003ff28,0)
 45296 fifotest RET   sigaltstack 0
 45296 fifotest CALL  sigprocmask(SIG_SETMASK,0<>)
 45296 fifotest RET   sigprocmask ~0x10100<SIGKILL|SIGSTOP>
 45296 fifotest CALL  __thrsleep(0xc420032bb8,CLOCK_MONOTONIC,0,0,0xc420032bb8)
 45296 fifotest RET   nanosleep 0
  <…>

I don't know much about go internals but might this be a userspace scheduling problem?

Complete ktrace output: https://github.com/golang/go/files/2435881/ktrace.txt

@nmeum

This comment has been minimized.

nmeum commented Nov 18, 2018

I can no longer reproduce this issue on OpenBSD 6.4 with go1.11. The TestFifoEOF test passes fine on OpenBSD 6.4. @ianlancetaylor could you confirm that this is the case, close this issue and reenable the test on OpenBSD?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment