You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem. Thanks.
What steps will reproduce the problem?
package main
Version 1.go:
-------------
import (
"fmt"
"runtime"
)
func main() {
F(15000000)
}
func F(n int) (r string) {
r2 := ""
for len(r2 + r) < n {
t := ""
for i := 0; i < 5000; i++ {
t += "10"
}
r += t
if len(r) > 1000000 {
fmt.Printf("Alloc: %12d\n", runtime.MemStats.Alloc)
r2 += r
r = ""
}
}
r2 += r
return r2[:n]
}
Version 0.go (crushes ever faster):
-----------------------------------
package main
import (
"fmt"
"runtime"
"crypto/rand"
)
func main() {
F(15000000)
b := make([]byte, 1000)
_, err := rand.Read(b)
if err != nil {
return
}
}
func F(n int) (r string) {
r2 := ""
for len(r2 + r) < n {
t := ""
for i := 0; i < 5000; i++ {
t += "10"
}
r += t
if len(r) > 1000000 {
fmt.Printf("Alloc: %10d\n", runtime.MemStats.Alloc)
r2 += r
r = ""
}
}
r2 += r
return r2[:n]
}
What is the expected output?
Output of 0.go compiled with 6g
Alloc: 2730712
Alloc: 4285864
Alloc: 6966696
Alloc: 6770088
Alloc: 13104552
Alloc: 13534632
Alloc: 17578920
Alloc: 19774376
Alloc: 18771368
Alloc: 17745320
Alloc: 16735656
Alloc: 16569768
Alloc: 58090368
Alloc: 60248960
What do you see instead?
Output 386 0.go
Alloc: 4590192
Alloc: 18337264
Alloc: 24819696
Alloc: 354659856
runtime: memory allocated by OS not in usable range
runtime: out of memory: cannot allocate 4325376-byte block (535953408 in use)
throw: out of memory
runtime.throw+0x43 /home/ubuntu/go/src/pkg/runtime/runtime.c:102
runtime.throw(0x80f3005, 0x413)
runtime.mallocgc+0x2cd /home/ubuntu/go/src/pkg/runtime/malloc.c:60
runtime.mallocgc(0x4127b1, 0x0, 0x1, 0x1, 0x0, ...)
runtime.mal+0x43 /home/ubuntu/go/src/pkg/runtime/malloc.c:289
runtime.mal(0x4127b1, 0x805bfb1)
runtime.gostringsize+0x49 /home/ubuntu/go/src/pkg/runtime/string.c:40
runtime.gostringsize(0x80fe4c, 0x4127b0, 0x2710)
concatstring+0x79 /home/ubuntu/go/src/pkg/runtime/string.c:126
concatstring(0x80fe88, 0x2, 0x80fe78, 0x80fe78)
runtime.concatstring+0x1f /home/ubuntu/go/src/pkg/runtime/string.c:141
runtime.concatstring(0x2, 0xaf067000, 0x3da540)
main.F+0x6a /home/ubuntu/test/0.go:21
main.F(0xe4e1c0, 0xb6c33000, 0x38270)
main.main+0x26 /home/ubuntu/test/0.go:10
main.main()
runtime.mainstart+0xf /home/ubuntu/go/src/pkg/runtime/386/asm.s:93
runtime.mainstart()
runtime.goexit /home/ubuntu/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xc1 /home/ubuntu/go/src/pkg/runtime/386/asm.s:80
--------------------------------------------------------------------------
Output 386 1.go
Alloc: 3840488
Alloc: 4666216
Alloc: 8051560
Alloc: 6943592
Alloc: 8584040
Alloc: 13527912
Alloc: 20775784
Alloc: 91599424
Alloc: 424534984
runtime: memory allocated by OS not in usable range
runtime: out of memory: cannot allocate 9175040-byte block (536805376 in use)
throw: out of memory
runtime.throw+0x43 /home/ubuntu/go/src/pkg/runtime/runtime.c:102
runtime.throw(0x80e9005, 0x8b1)
runtime.mallocgc+0x2cd /home/ubuntu/go/src/pkg/runtime/malloc.c:60
runtime.mallocgc(0x8b01f1, 0x0, 0x1, 0x1, 0x0, ...)
runtime.mal+0x43 /home/ubuntu/go/src/pkg/runtime/malloc.c:289
runtime.mal(0x8b01f1, 0x805bf4a)
runtime.gostringsize+0x49 /home/ubuntu/go/src/pkg/runtime/string.c:40
runtime.gostringsize(0x307e8c, 0x8b01f0, 0x2710)
concatstring+0x79 /home/ubuntu/go/src/pkg/runtime/string.c:126
concatstring(0x307ec8, 0x2, 0x307eb8, 0x307eb8)
runtime.concatstring+0x1f /home/ubuntu/go/src/pkg/runtime/string.c:141
runtime.concatstring(0x2, 0xb5d6d000, 0x8ab3d0)
main.F+0x6a /home/ubuntu/test/1.go:14
main.F(0xe4e1c0, 0xb451f000, 0x4e20)
main.main+0x26 /home/ubuntu/test/1.go:9
main.main()
runtime.mainstart+0xf /home/ubuntu/go/src/pkg/runtime/386/asm.s:93
runtime.mainstart()
runtime.goexit /home/ubuntu/go/src/pkg/runtime/proc.c:178
runtime.goexit()
----- goroutine created by -----
_rt0_386+0xc1 /home/ubuntu/go/src/pkg/runtime/386/asm.s:80
Which compiler are you using (5g, 6g, 8g, gccgo)?
8g
Which operating system are you using?
ubuntu 10.04, 10.10, 11.04
Which revision are you using? (hg identify)
e1e194eb5c8e (release-branch.r57)
Please provide any additional information below.
The text was updated successfully, but these errors were encountered:
by goprogger@gmx.de:
The text was updated successfully, but these errors were encountered: