[go-nuts] http request blocked on futex .

2017-05-11 Thread Dave Cheney
Go programs are multi threaded, you should use the -f flag with strace to watch 
all threads servicing goroutines. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] http request blocked on futex .

2017-05-11 Thread yikang zhuo
hi all,

iI write a simple golang program below and build a execute file.

package main

import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)

func main() {
data := "line=ls"
// resp, err := http.Post("http://127.0.0.1:3202/run;, 
"application/x-www-form-urlencoded",
resp, err := http.Post("http://192.168.1.109:3202/run;, 
"application/x-www-form-urlencoded",
strings.NewReader(data))
if err != nil {
fmt.Println(err)
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("remote run error\n")
}

fmt.Printf("%s", body)
}

when I compile and execute the program, it will block for almost 1 minutes 
and return , but the   err  whch in red color code above  is nil 
in the same time, the server which serves on 3202 doesn't get any request.

but if I execute it with sudo.  it works fine.  

I think it's not golang's  problem because I get the same performance with 
curl

blocked:curl  http://192.168.1.109:3202/run
works fine:sudo http://192.168.1.109:3202/run


so I  strace it without sudo . and get such stack:


➜  tr strace ./tr 
execve("./tr", ["./tr"], [/* 116 vars */]) = 0
brk(NULL)   = 0xe9c000
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc7982000
access("/etc/ld.so.preload", R_OK)  = -1 ENOENT (No such file or 
directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=138563, ...}) = 0
mmap(NULL, 138563, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4dc796
close(3)= 0
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, 
"\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260`\0\0\0\0\0\0"..., 832) 
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=138696, ...}) = 0
mmap(NULL, 2212904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0x7f4dc7542000
mprotect(0x7f4dc755a000, 2093056, PROT_NONE) = 0
mmap(0x7f4dc7759000, 8192, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7f4dc7759000
mmap(0x7f4dc775b000, 13352, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4dc775b000
close(3)= 0
access("/etc/ld.so.nohwcap", F_OK)  = -1 ENOENT (No such file or 
directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 
832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 
0x7f4dc7179000
mprotect(0x7f4dc7338000, 2097152, PROT_NONE) = 0
mmap(0x7f4dc7538000, 24576, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f4dc7538000
mmap(0x7f4dc753e000, 14752, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4dc753e000
close(3)= 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc795f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc795e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc795d000
arch_prctl(ARCH_SET_FS, 0x7f4dc795e700) = 0
mprotect(0x7f4dc7538000, 16384, PROT_READ) = 0
mprotect(0x7f4dc7759000, 4096, PROT_READ) = 0
mprotect(0x7f4dc7984000, 4096, PROT_READ) = 0
munmap(0x7f4dc796, 138563)  = 0
set_tid_address(0x7f4dc795e9d0) = 31710
set_robust_list(0x7f4dc795e9e0, 24) = 0
rt_sigaction(SIGRTMIN, {0x7f4dc7547b50, [], SA_RESTORER|SA_SIGINFO, 
0x7f4dc7553390}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f4dc7547be0, [], 
SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f4dc7553390}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL)   = 0xe9c000
brk(0xebd000)   = 0xebd000
sched_getaffinity(0, 8192, [f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]) = 64
mmap(0xc0, 65536, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xc0
munmap(0xc0, 65536) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x7f4dc791d000
mmap(0xc42000, 1048576, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xc42000
mmap(0xc41fff8000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = 0xc41fff8000
mmap(0xc0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = 0xc0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc7972000
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7f4dc7962000
rt_sigprocmask(SIG_SETMASK,