Skip to content

panic in StringVector.Data()  #294

@gopherbot

Description

@gopherbot

by bslesinsky:

What steps will reproduce the problem?

Compile and run:

package main

import (
    "container/vector";
    "fmt"
)

func main() {
    x := vector.NewStringVector(2);
    x.Push("hello ");
    x.Push("world");
    for s := range(x.Data()) {
        fmt.Print(s)
    }
}


What is the expected output? What do you see instead?

It should print "hello world". Instead:

$ ./8.out
interface is nil, not string
throw: interface conversion

panic PC=0xa4f10
throw+0x46 /Users/skybrian/go/src/pkg/runtime/runtime.c:74
    throw(0x4839f, 0x35c4c)
runtime·ifaceE2T+0x48 /Users/skybrian/go/src/pkg/runtime/iface.c:262
    runtime·ifaceE2T(0x4816c, 0x0, 0x0)
vector·*StringVector·Data+0xd4
/Users/skybrian/go/src/pkg/container/vector/stringvector.go:42
    vector·*StringVector·Data(0xa12b0, 0x48014, 0x5)
main·main+0x65 /Users/skybrian/tmp/bug.go:12
    main·main()
mainstart+0xf /Users/skybrian/go/src/pkg/runtime/386/asm.s:81
    mainstart()
goexit /Users/skybrian/go/src/pkg/runtime/proc.c:135
    goexit()

What is your $GOOS?  $GOARCH?

$ echo $GOOS $GOARCH
darwin 386

Which revision are you using?  (hg identify)

$ hg identify
44699e529c44+ tip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions