<pre class="notranslate">windows-386 builder failed during CL 153240043 submission:

<a href="http://build.golang.org/log/04f483224055ef6972746ab22c53271c05ce85b8" rel="nofollow">http://build.golang.org/log/04f483224055ef6972746ab22c53271c05ce85b8</a>


# GOMAXPROCS=2 runtime -cpu=1,2,4
--- FAIL: TestLockedDeadlock-4 (0.03s)
    crash_test.go:72: failed to execute 'go list': exit status 2
        runtime: garbage collector found invalid heap pointer *(0x12454320+0x10)=0x12475fe4 span=0x12470000-0x0-0x12550000 state=2
        runtime: found *(0x12464000+0x14) = 0x12454320+0x0
        runtime: found *(0x12462000+0x4c) = 0x12464000+0x0
        runtime: found *(0x933d00+0x16a4) = 0x12462000+0x0
        fatal error: bad pointer
        
        runtime stack:
        runtime.throw(0x929b90)
            c:/go/src/runtime/panic.go:492 +0x83 fp=0xcfc68 sp=0xcfc50
        scanblock(0x933d00, 0x8fe0, 0x32c5c0)
            c:/go/src/runtime/mgc0.c:410 +0x759 fp=0xcfd08 sp=0xcfc68
        markroot(0x1245a190, 0x1)
            c:/go/src/runtime/mgc0.c:495 +0x139 fp=0xcfd40 sp=0xcfd08
        runtime.parfordo(0x1245a190)
            c:/go/src/runtime/parfor.c:91 +0x115 fp=0xcfd9c sp=0xcfd40
        gc(0xcfed8)
            c:/go/src/runtime/mgc0.c:1438 +0x1fb fp=0xcfec8 sp=0xcfd9c
        runtime.gc_m()
            c:/go/src/runtime/mgc0.c:1372 +0xe7 fp=0xcfee8 sp=0xcfec8
        runtime.onM(0x934d58)
            c:/go/src/runtime/asm_386.s:266 +0x50 fp=0xcfeec sp=0xcfee8
        runtime.mstart()
            c:/go/src/runtime/proc.c:786 fp=0xcfef0 sp=0xcfeec
        
        goroutine 1 [garbage collection, locked to thread]:
        runtime.switchtoM()
            c:/go/src/runtime/asm_386.s:208 fp=0x1246de88 sp=0x1246de84
        runtime.gogc(0x0)
            c:/go/src/runtime/malloc.go:469 +0x1aa fp=0x1246dea8 sp=0x1246de88
        runtime.mallocgc(0x20, 0x71fe00, 0x0, 0x0)
            c:/go/src/runtime/malloc.go:341 +0x2c4 fp=0x1246df00 sp=0x1246dea8
        runtime.newobject(0x71fe00, 0x1)
            c:/go/src/runtime/malloc.go:353 +0x48 fp=0x1246df14 sp=0x1246df00
        runtime.makemap(0x6c4d80, 0x0, 0x0, 0x0)
            c:/go/src/runtime/hashmap.go:220 +0x32e fp=0x1246df4c sp=0x1246df14
        unicode.init()
            c:/go/src/unicode/tables.go:52 +0x5c fp=0x1246df6c sp=0x1246df4c
        go/parser.init()
            c:/go/src/go/parser/parser.go:2462 +0x45 fp=0x1246df78 sp=0x1246df6c
        main.init()
            c:/go/src/cmd/go/zdefaultcc.go:6 +0x45 fp=0x1246dfcc sp=0x1246df78
        runtime.main()
            c:/go/src/runtime/proc.go:58 +0xbd fp=0x1246dff0 sp=0x1246dfcc
        runtime.goexit()
            c:/go/src/runtime/proc.c:1651 fp=0x1246dff4 sp=0x1246dff0
        
        goroutine 2 [runnable]:
        runtime.forcegchelper()
            c:/go/src/runtime/proc.go:90 fp=0x1246aff0 sp=0x1246afec
        runtime.goexit()
            c:/go/src/runtime/proc.c:1651 fp=0x1246aff4 sp=0x1246aff0
        created by runtime.init·4
            c:/go/src/runtime/proc.go:87 +0x25
        
        goroutine 3 [runnable]:
        runtime.bgsweep()
            c:/go/src/runtime/mgc0.go:66 fp=0x1246cff0 sp=0x1246cfec
        runtime.goexit()
            c:/go/src/runtime/proc.c:1651 fp=0x1246cff4 sp=0x1246cff0
        created by gc
            c:/go/src/runtime/mgc0.c:1382
FAIL
FAIL    runtime 37.175s
Build complete, duration 1m41.483389s. Result: error: exit status 1

Alex</pre>
<pre class="notranslate">What steps will reproduce the problem?

<a href="http://play.golang.org/p/3vfzRJflIm" rel="nofollow">http://play.golang.org/p/3vfzRJflIm</a>

What is the expected output? All rows should be in increasing order.

0 1 2
1 2 3
2 3 4
...

What do you see instead? Some values are duplicated.

0 1 2
1 2 3
4 4 4
...

Which compiler/os/version are you using?

6g, Windows 7, version 1.0.2


It seems that append is not thread-safe function although it looks like a pure function.
Maybe this possible problem should be more explicitly documented. It has this bad
property of almost working correctly.

If the declaration for append would be something like:
  func append(slice *[]Type, elems ...Type)

it would make modification of the underlying slice visible.

The fix for the program is trivial:

a := make([]int, len(x)+1)
copy(a, x)
a[len(a)-1] = i</pre>