Simple web server crashes with a "throw: malloc / free - deadlock"

143 views
Skip to first unread message

Alexey

unread,
Apr 6, 2011, 6:06:29 PM4/6/11
to golang-nuts
I used the "8g version weekly.2011-04-04 8003" to compile a simple Web
server from the documentation on Go.

-------------------------------------------------------------------------------------------------------
package main

import (
"http"
"io"
"log"
"runtime"
)

// hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "hello, world!\n")
}

func main() {
runtime.GOMAXPROCS(1)
http.HandleFunc("/hello", HelloServer)
err := http.ListenAndServe(":12345", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err.String())
}
}
-------------------------------------------------------------------------------------------------------

Starting the server's memory usage was as follows: 1,7 Mb Virtual:
776,2 Mb

After the first run Apache benchmark tools (ab -r -n 900000 -c 1000
http://localhost:12345/) server memory usage was as follows: 421.2 Mb
Virtual: 786.3 Mb

After the second run Apache benchmark tools (ab -r -n 900000 -c 1000
http://localhost:12345/) application has fallen with the message
"throw: malloc / free - deadlock".

I ran the test on Intel Core i5 M460 with 4Gb memory
During testing, the memory usage always increases.

-------------------------------------------------------------------------------------------------------
throw: malloc/free - deadlock

[signal 0xb code=0x1 addr=0x0 pc=0x804ebbd]

runtime.throw+0x43 /home/alexey/go/src/pkg/runtime/runtime.c:102
runtime.throw(0x8216e58, 0xb77b7560)
runtime.mallocgc+0x67 /home/alexey/go/src/pkg/runtime/malloc.c:36
runtime.mallocgc(0x8, 0x0, 0x1, 0x1, 0x1, ...)
runtime.mal+0x43 /home/alexey/go/src/pkg/runtime/malloc.c:289
runtime.mal(0x8, 0x8058f7d)
copyin+0x64 /home/alexey/go/src/pkg/runtime/iface.c:160
copyin(0x81020ac, 0x86af19bc, 0x86af19c8, 0x82264a0)
runtime.convT2E+0x46 /home/alexey/go/src/pkg/runtime/iface.c:209
runtime.convT2E(0x81020ac, 0x8216897)
runtime.newErrorString+0x34 /home/alexey/go/src/pkg/runtime/error.go:
107
runtime.newErrorString(0x8216897, 0x31, 0x86af19fc, 0x86291c8)
runtime.panicstring+0x81 /home/alexey/go/src/pkg/runtime/runtime.c:115
runtime.panicstring(0x8216897, 0x5)
runtime.sigpanic+0x11b /home/alexey/go/src/pkg/runtime/linux/thread.c:
292
runtime.sigpanic()
runtime.MCache_Alloc+0x96 /home/alexey/go/src/pkg/runtime/mcache.c:29
runtime.MCache_Alloc(0x877ca5f0, 0xd, 0xc0, 0x1, 0x1, ...)
runtime.mallocgc+0xe1 /home/alexey/go/src/pkg/runtime/malloc.c:47
runtime.mallocgc(0xc0, 0x0, 0x1, 0x1, 0x0, ...)
runtime.mal+0x43 /home/alexey/go/src/pkg/runtime/malloc.c:289
runtime.mal(0xb4, 0x0)
hash_subtable_new+0x72 /home/alexey/go/src/pkg/runtime/hashmap.c:98
hash_subtable_new(0xb77c3190, 0x2, 0x0, 0xb77bb3c0)
hash_grow+0x51 /home/alexey/go/src/pkg/runtime/hashmap.c:273
hash_grow(0xb77c3190, 0xb77c31a8, 0x0, 0x2)
hash_insert_internal+0x148 /home/alexey/go/src/pkg/runtime/hashmap.c:
450
hash_insert_internal(0xb77c31a8, 0x0, 0x88af780, 0xb77c3190,
0x86af1bbc, ...)
hash_insert+0x6d /home/alexey/go/src/pkg/runtime/hashmap.c:460
hash_insert(0xb77c3190, 0x86af1bbc, 0x86af1b90, 0x1)
runtime.mapassign+0x8a /home/alexey/go/src/pkg/runtime/hashmap.c:876
runtime.mapassign(0xb77c3190, 0x86af1bbc, 0x86af1bc4, 0x3)
runtime.mapassign1+0x45 /home/alexey/go/src/pkg/runtime/hashmap.c:910
runtime.mapassign1(0xb77c3190, 0xb77b7640)
net/textproto.*Reader·ReadMIMEHeader+0x2e9 /home/alexey/go/src/pkg/net/
textproto/reader.go:446
net/textproto.*Reader·ReadMIMEHeader(0xb778ded8, 0x1, 0xb77c3140)
http.ReadRequest+0x342 /home/alexey/go/src/pkg/http/request.go:453
http.ReadRequest(0xb77aa7b0, 0xb77ae480, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb77aa780, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb77aa780, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1341322 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb59e5200, 0x86af2740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb59e5200, 0xb618d680)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb618d680, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb618d680, 0xb6a5c000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xb59e1b80, 0xb6a5c000, 0x1000, 0x1000,
0xb59e1e30, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xb62f17e0, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xb62f17e0, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xb62f17e0, 0xb59e1c0a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xb59e1bb8, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xb59e1bb8, 0xb618d700, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xb62f17e0, 0xb618d700, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb62f17b0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb62f17b0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1324483 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xad673a80, 0x86aef740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xad673a80, 0xa0fb1180)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xa0fb1180, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xa0fb1180, 0xa20e5000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xa1d85530, 0xa20e5000, 0x1000, 0x1000,
0xa1d856a0, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xa100a0f0, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xa100a0f0, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xa100a0f0, 0xa1d8560a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xa1d85758, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xa1d85758, 0xa0979700, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xa100a0f0, 0xa0979700, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xa100a0c0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xa100a0c0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1338643 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb71ef480, 0x86ae8740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb71ef480, 0xb21dcc00)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb21dcc00, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb21dcc00, 0xb2e29000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xb2dff610, 0xb2e29000, 0x1000, 0x1000,
0xb2dff438, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xb405f300, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xb405f300, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xb405f300, 0xb2dff00a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xb2dff450, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xb2dff450, 0xafc7c300, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xb405f300, 0xafc7c300, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb405f2d0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb405f2d0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1341323 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb59e5280, 0x86ae7740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb59e5280, 0xb618d780)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb618d780, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb618d780, 0xb6a7d000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xb59e1be8, 0xb6a7d000, 0x1000, 0x1000,
0xb59e1f50, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xb62f1840, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xb62f1840, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xb62f1840, 0xb59e1e0a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xb59e1f68, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xb59e1f68, 0xb62f0200, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xb62f1840, 0xb62f0200, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb62f1810, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb62f1810, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1336652 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb59bcf40, 0x86ae5740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb59bcf40, 0xac44aa80)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xac44aa80, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xac44aa80, 0xa7fed000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xacbcf790, 0xa7fed000, 0x1000, 0x1000,
0xacbcf6b0, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xae2593f0, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xae2593f0, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xae2593f0, 0xacbcf60a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xacbcf7c8, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xacbcf7c8, 0xac44ab00, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xae2593f0, 0xac44ab00, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xae2593c0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xae2593c0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1337544 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb52c94c0, 0x86ae4740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb52c94c0, 0xb17a8880)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb17a8880, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb17a8880, 0xae179000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xae070f58, 0xae179000, 0x1000, 0x1000,
0xae070df8, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xae6c03f0, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xae6c03f0, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xae6c03f0, 0xae070d0a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xae070f90, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xae070f90, 0xb17a8900, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xae6c03f0, 0xb17a8900, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xae6c03c0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xae6c03c0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1323799 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb0903140, 0x86ae3740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb0903140, 0x9f8ffc00)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0x9f8ffc00, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0x9f8ffc00, 0xa1d81000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xa0582070, 0xa1d81000, 0x1000, 0x1000,
0x9fdeed78, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xa075ba20, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xa075ba20, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xa075ba20, 0x9fdeed0a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xa0582080, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xa0582080, 0x9f8ffc80, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xa075ba20, 0x9f8ffc80, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xa075b9f0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xa075b9f0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1340191 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb1e59100, 0x86ae0740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb1e59100, 0xb486d200)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb486d200, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb486d200, 0xb47b9000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xb52fc2e8, 0xb47b9000, 0x1000, 0x1000,
0xb52fc2a8, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xb6147630, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xb6147630, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xb6147630, 0xb52fc20a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xb52fc140, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xb52fc140, 0xb51baa00, 0xa)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xb6147630, 0xb51baa00, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb6147600, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb6147600, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1342809 [1]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.exitsyscall+0x6d /home/alexey/go/src/pkg/runtime/proc.c:665
runtime.exitsyscall()
syscall.Syscall+0x53 /home/alexey/go/src/pkg/syscall/asm_linux_386.s:
33
syscall.Syscall()
syscall.Close+0x43 /home/alexey/go/src/pkg/syscall/
zsyscall_linux_386.go:142
syscall.Close(0xd, 0x1, 0x1)
os.*File·Close+0x4f /home/alexey/go/src/pkg/os/file_unix.go:50
os.*File·Close(0xb77c20c0, 0x8053e00, 0x0)
net.*netFD·decref+0x94 /home/alexey/go/src/pkg/net/fd.go:340
net.*netFD·decref(0xb7782600, 0x2)
net.*netFD·Close+0x67 /home/alexey/go/src/pkg/net/fd.go:355
net.*netFD·Close(0xb7782600, 0x1, 0x0)
net.*TCPConn·Close+0x51 /home/alexey/go/src/pkg/net/tcpsock.go:110
net.*TCPConn·Close(0xb77b73b0, 0x0, 0x0)
http.*conn·close+0x77 /home/alexey/go/src/pkg/http/server.go:437
http.*conn·close(0xb77aa720, 0x979eb480)
http.*conn·serve+0x4d /home/alexey/go/src/pkg/http/server.go:463
http.*conn·serve(0xb77aa720, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1325497 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xafa86900, 0x86b19740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xafa86900, 0xa64efa80)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xa64efa80, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xa64efa80, 0xa6890000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xa7a0a8f0, 0xa6890000, 0x1000, 0x1000,
0xa7a0aa28, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xa6f82600, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xa6f82600, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xa6f82600, 0xa7a0a90a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xa7a0ab28, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xa7a0ab28, 0xa64efb00, 0x0)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xa6f82600, 0xa64efb00, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xacd51bd0, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xacd51bd0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 1342733 [4]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.chanrecv+0x153 /home/alexey/go/src/pkg/runtime/chan.c:377
runtime.chanrecv(0xb76c1c80, 0x86b13740, 0x0, 0x0, 0x1000, ...)
runtime.chanrecv1+0x3f /home/alexey/go/src/pkg/runtime/chan.c:439
runtime.chanrecv1(0xb76c1c80, 0xb7642e80)
net.*pollServer·WaitRead+0x4a /home/alexey/go/src/pkg/net/fd.go:255
net.*pollServer·WaitRead(0x977faba0, 0xb7642e80, 0x1000)
net.*netFD·Read+0x1c1 /home/alexey/go/src/pkg/net/fd.go:380
net.*netFD·Read(0xb7642e80, 0xb76d3000, 0x1000, 0x1000, 0x0, ...)
net.*TCPConn·Read+0x6f /home/alexey/go/src/pkg/net/tcpsock.go:94
net.*TCPConn·Read(0xb76b0cf8, 0xb76d3000, 0x1000, 0x1000,
0xb76b0d00, ...)
bufio.*Reader·fill+0x152 /home/alexey/go/src/pkg/bufio/bufio.go:97
bufio.*Reader·fill(0xb76d2030, 0x0)
bufio.*Reader·ReadSlice+0x25a /home/alexey/go/src/pkg/bufio/bufio.go:
267
bufio.*Reader·ReadSlice(0xb76d2030, 0xf0a, 0x0, 0x0, 0x0, ...)
bufio.*Reader·ReadBytes+0x86 /home/alexey/go/src/pkg/bufio/bufio.go:
300
bufio.*Reader·ReadBytes(0xb76d2030, 0xb76b0b0a, 0x0, 0x0, 0x0, ...)
net/textproto.*Reader·ReadLineBytes+0x3c /home/alexey/go/src/pkg/net/
textproto/reader.go:43
net/textproto.*Reader·ReadLineBytes(0xb76b0d40, 0x80, 0x0)
net/textproto.*Reader·ReadLine+0x29 /home/alexey/go/src/pkg/net/
textproto/reader.go:36
net/textproto.*Reader·ReadLine(0xb76b0d40, 0xb764fd80, 0x0)
http.ReadRequest+0x7f /home/alexey/go/src/pkg/http/request.go:431
http.ReadRequest(0xb76d2030, 0xb764fd80, 0x0, 0x0)
http.*conn·readRequest+0x6e /home/alexey/go/src/pkg/http/server.go:171
http.*conn·readRequest(0xb76d2000, 0x979eb480, 0x0, 0x0)
http.*conn·serve+0x29 /home/alexey/go/src/pkg/http/server.go:445
http.*conn·serve(0xb76d2000, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
http.*Server·Serve+0x1cf /home/alexey/go/src/pkg/http/server.go:775

goroutine 2 [3]:
runtime.entersyscall+0x18 /home/alexey/go/src/pkg/runtime/proc.c:620
runtime.entersyscall()
syscall.Syscall6+0x5 /home/alexey/go/src/pkg/syscall/asm_linux_386.s:
38
syscall.Syscall6()
syscall.EpollWait+0x74 /home/alexey/go/src/pkg/syscall/
zsyscall_linux_386.go:200
syscall.EpollWait(0x6, 0x9781cf08, 0xa, 0xa, 0xffffffff, ...)
net.*pollster·WaitFD+0x147 /home/alexey/go/src/pkg/net/fd_linux.go:130
net.*pollster·WaitFD(0x9781cf00, 0x977faba0, 0x0, 0x0, 0x7, ...)
net.*pollServer·Run+0x10a /home/alexey/go/src/pkg/net/fd.go:226
net.*pollServer·Run(0x977faba0, 0x0)
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x344 /home/alexey/go/src/pkg/net/newpollserver.go:
39

goroutine 1 [1]:
runtime.gosched+0x6d /home/alexey/go/src/pkg/runtime/proc.c:600
runtime.gosched()
runtime.exitsyscall+0x6d /home/alexey/go/src/pkg/runtime/proc.c:665
runtime.exitsyscall()
syscall.Syscall+0x53 /home/alexey/go/src/pkg/syscall/asm_linux_386.s:
33
syscall.Syscall()
syscall.fcntl+0x43 /home/alexey/go/src/pkg/syscall/
zsyscall_linux_386.go:264
syscall.fcntl(0xe, 0x2, 0x1, 0xb77269a0, 0x4, ...)
syscall.CloseOnExec+0x39 /home/alexey/go/src/pkg/syscall/exec_unix.go:
74
syscall.CloseOnExec(0xe, 0xe)
net.*netFD·accept+0x1ff /home/alexey/go/src/pkg/net/fd.go:612
net.*netFD·accept(0x9781ff80, 0x80a3149, 0x0, 0x0, 0x0, ...)
net.*TCPListener·AcceptTCP+0x56 /home/alexey/go/src/pkg/net/tcpsock.go:
262
net.*TCPListener·AcceptTCP(0x977ea3a0, 0x8, 0x0, 0x0)
net.*TCPListener·Accept+0x39 /home/alexey/go/src/pkg/net/tcpsock.go:
272
net.*TCPListener·Accept(0x977ea3a0, 0x0, 0x0, 0x0, 0x0, ...)
http.*Server·Serve+0xb5 /home/alexey/go/src/pkg/http/server.go:761
http.*Server·Serve(0x97806c60, 0x97860080, 0x977ea3a0, 0x0, 0x0, ...)
http.*Server·ListenAndServe+0xb5 /home/alexey/go/src/pkg/http/
server.go:748
http.*Server·ListenAndServe(0x97806c60, 0x97806c60, 0x805335b)
http.ListenAndServe+0x55 /home/alexey/go/src/pkg/http/server.go:809
http.ListenAndServe(0x814a37c, 0x6, 0x0, 0x0, 0x804e73b, ...)
main.main+0x59 /home/alexey/src/temp/server/server.go:18
main.main()
runtime.mainstart+0xf /home/alexey/go/src/pkg/runtime/386/asm.s:93
runtime.mainstart()
runtime.goexit /home/alexey/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xc1 /home/alexey/go/src/pkg/runtime/386/asm.s:80

ziutek

unread,
Apr 7, 2011, 4:43:58 AM4/7/11
to golang-nuts
It happened to me too, with godoc -http=:8080 and the same 8g release.
I've tried reproduce it, but I couldn't.

John Beisley

unread,
Apr 7, 2011, 5:13:18 AM4/7/11
to golang-nuts
I can also confirm seeing this on godoc -http=:8080 - on a weekly
release prior to 4th April (I think it was the previous release). I
don't have any reproduction steps either, I'm afraid. Using the 8g
compiled version on Linux.

Dave Cheney

unread,
Apr 7, 2011, 5:54:58 AM4/7/11
to John Beisley, golang-nuts
The common thread here appears to be 8g. My suggestion is the runtime
has run out of address space as the crash looks like a malloc failure
while reporting a previous failure.

I would be suspicious that this isn't a memory leak of sorts inside
the http code that is keeping old references around.

Cheers

Dave

Jim Whitehead II

unread,
Apr 7, 2011, 6:20:07 AM4/7/11
to golang-nuts

I reported this issue previously [1] and there hasn't been any
progress with it yet. I was able to *reliably* reproduce this in my
test environment but it's a somewhat complicated procedure. If anyone
can provide further information about this issue, I would greatly
appreciate it.

[1]: http://code.google.com/p/go/issues/detail?id=1537

- Jim

Martin Capitanio

unread,
Apr 7, 2011, 6:25:19 AM4/7/11
to golan...@googlegroups.com, John Beisley


On Thursday, April 7, 2011 11:54:58 AM UTC+2, Dave Cheney wrote:
The common thread here appears to be 8g. My suggestion is the runtime
has run out of address space as the crash looks like a malloc failure
while reporting a previous failure.

I would be suspicious that this isn't a memory leak of sorts inside
the http code that is keeping old references around.

I think you are right. It happens at least with the latest 6g too. As Alexey wrote,
running the ab benchmark causes permanent increases of VIRT/RES memory.
(You can also reproduce this running ab against the godoc server.)

Dave Cheney

unread,
Apr 7, 2011, 7:49:28 AM4/7/11
to golan...@googlegroups.com, Martin Capitanio, John Beisley
On a hunch that the problem may be in pkg/net, not pkg/http I knocked
up a quick test.

https://gist.github.com/907622

I see the same pattern of allocated memory (as reported by
runtime.MemStats) as with Alexys's previous example. I would
appreciate it if those having this problem would try this code and we
can compare notes.

Cheers

Dave

André Moraes

unread,
Apr 7, 2011, 8:18:41 AM4/7/11
to golan...@googlegroups.com
I maybe wrong, but things start to go bad at:

net/textproto.*Reader·ReadMIMEHeader+0x2e9 /home/alexey/go/src/pkg/net/
textproto/reader.go:446
net/textproto.*Reader·ReadMIMEHeader(0xb778ded8, 0x1, 0xb77c3140)
http.ReadRequest+0x342 /home/alexey/go/src/pkg/http/request.go:453

After the net/textproto.ReadMIMEHeader the runtime start the
allocation process and then "panic" happens.

Also go http package is still young and propably not optimized for
that load so it should stay behind a ngnix or apahce server.
But would be very nice to have a Go webserver in front of everything. :)

Martin Capitanio

unread,
Apr 7, 2011, 8:36:28 AM4/7/11
to golan...@googlegroups.com, Martin Capitanio, John Beisley
hg sum
parent: 8006:f618e5e0991d tip

./listen
397792 389568
433464 423416
434176 423416

ab -v10 -r -n 900000 -c 1000 http://localhost:12345/
Test aborted after 10 failures
apr_socket_connect(): Cannot assign requested address (99)
Total of 28905 requests completed
12623376 12622760
31439616 31419712
29506432 29484160
29507144 29484160
29507856 29484160
29508568 29507096
29509280 29507096

ab -v10 -r -n 900000 -c 1000 http://localhost:12345/
Test aborted after 10 failures
apr_socket_connect(): Cannot assign requested address (99)
Total of 29714 requests completed
38375816 38372976
52940992 52921536
59285352 59281136
59286064 59281136
59286776 59281136

PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
16867 mc        20   0  103M 66756   808 S  0.0  1.8  0:01.96 ./listen
16868 mc        20   0  103M 66756   808 S  0.0  1.8  0:03.48 ./listen
16869 mc        20   0  103M 66756   808 S  0.0  1.8  0:00.95 ./listen 
16877 mc        20   0  103M 66756   808 S  0.0  1.8  0:00.00 ./listen 

Alexey

unread,
Apr 7, 2011, 8:46:52 AM4/7/11
to golang-nuts
Try to run ab without options -v10.

Martin Capitanio

unread,
Apr 7, 2011, 10:30:17 AM4/7/11
to golan...@googlegroups.com
On Thursday, April 7, 2011 2:46:52 PM UTC+2, Alexey wrote:
Try to run ab without options -v10.

On Apr 7, 4:36 pm, Martin Capitanio <m....@capitanio.org> wrote:
> ab -v10 -r -n 900000 -c 1000http://localhost:12345/

That's just coincidence, ab -r always aborts after 10 failures:

E.g. running Dave's test and ab on different machines (plus limiting the
memory to 500MB) shows a leak ca 700k/request:

ab  -r -n 900000 -c 1000 http://192.168.10.10:12345/
Completed 90000 requests
Completed 180000 requests
Completed 270000 requests
Completed 360000 requests
Completed 450000 requests
Completed 540000 requests
Completed 630000 requests

Test aborted after 10 failures

apr_socket_connect(): Connection reset by peer (104)
Total of 715016 requests completed

----

ulimit -Sv 500000
./listen 
387720 387720
433464 422560
11040520 11038296
23283896 23276320
27595192 27583136
32963176 32954672
32763496 32752592
43155584 43151912
54413328 54408856
...
375453784 375440872
383157840 383150152
390794592 390782536
398539280 398523264
406201904 406191392
413910152 413899312
421941616 421915504
runtime: address space conflict: map(0xf859c40000) = 0xc
throw: runtime: address space conflict
...

Martin Capitanio

unread,
Apr 7, 2011, 3:05:52 PM4/7/11
to golan...@googlegroups.com, Martin Capitanio, John Beisley
Strangely enough, gccgo works as expected :-)

Benchmarking 192.168.10.10 (be patient)
Completed 90000 requests
...
Completed 900000 requests
Finished 900000 requests

----

./a.out
94496 94512
106040 96608
115040 105624
124040 114624
133040 123624
142040 132624
109280 105912
138000 137704
184464 185048
175568 175072
121040 105920
143432 144808
124936 105920
142488 105920
177584 176168
156000 156096
165000 156704
174000 165704
209144 208096
139192 125960
...
83664 143112
92664 152112
101664 161112
110664 170112
119664 179112
128664 188112
137664 197112
146664 206112
38664 106320
47664 107112
56664 116112
65664 125112

Dave Cheney

unread,
Apr 7, 2011, 8:19:52 PM4/7/11
to golan...@googlegroups.com
Digging into this further, running this code

https://gist.github.com/909061

c5c62aeb6267+ release/release.r56/weekly.2011-03-07.1

the memory usage stabalises

on tip it grows (albeit slowly) without limit.

Cheers

Dave

Dave Cheney

unread,
Apr 8, 2011, 12:00:31 AM4/8/11
to golan...@googlegroups.com
For those watching this issue, take a wander over to
http://code.google.com/p/go/issues/detail?id=1676 for more details.

Cheers

Dave

Reply all
Reply to author
Forward
0 new messages