Skip to content

Crash in Iconv.DoWrite #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RinTohsaka opened this issue Dec 3, 2015 · 1 comment
Closed

Crash in Iconv.DoWrite #30

RinTohsaka opened this issue Dec 3, 2015 · 1 comment

Comments

@RinTohsaka
Copy link

Hello! I'm not sure if it's issue with iconv or Go iteself, but my program randomly crashes. The code:

func main() {
        in := make(chan []byte)
        dir := os.Args[1]
        files, err := ioutil.ReadDir(dir)
        if err != nil {
                panic(err)
        }

        go func() {
                cd, err := iconv.Open("UTF-8", "CP932")
                if err != nil {
                        panic(err)
                }
                for data := range in {
                        cd.ConvString(string(data))
                }
        }()

        iterations := 1000
        for i := 0; i < iterations; i++ {
                for _, file := range files {
                        file, err := os.Open(path.Join(dir, file.Name()))
                        if err != nil {
                                panic(err)
                        }
                        data, err := ioutil.ReadAll(file)
                        if err != nil {
                                panic(err)
                        }
                        in <- data
                        file.Close()
                }
        }
        close(in)
}

And after some (random) time executing this code program crashes with:

runtime:objectstart Span weird: p=0xc820880000 k=0x6410440 s.start=0xc820880000 s.limit=0xc820884000 s.state=2
fatal error: objectstart: bad pointer in unexpected span

exit status 2
1: running [Created by runtime.gcBgMarkStartWorkers @ mgc.go:1239]
    runtime panic.go:527                throw(0x542a00, 0x2b)
    runtime mbitmap.go:217              heapBitsForObject(0xc820880000, 0, 0, 0xc800000000, 0x7fa7d82f41a0)
    runtime mgcmark.go:878              scanobject(0xc820770208, #1)
    runtime mgcmark.go:689              gcDrain(#1, 0x7d0)
    runtime mgc.go:1320                 gcBgMarkWorker(0xc820028000)
    runtime asm_amd64.s:1696            goexit()
1: runnable [locked] [Created by main.main @ test.go:44]
    iconv   _cgo_gotypes.go:49          _C2func_iconv(#14, #4, #9, #12, #11, 0xffffffffffffffff, 0, 0)
    iconv   iconv.go:102                Iconv.DoWrite(#14, #15, #10, #8, 0x1a38, 0x1e04, 0x1a38, #5, 0x200, 0x200, ...)
    iconv   iconv.go:61                 Iconv.Conv(#14, #7, 0x1c34, 0x2000, #5, 0x200, 0x200, 0, 0, 0, ...)
    iconv   iconv.go:68                 Iconv.ConvString(#14, #6, 0x1c34, 0, 0)
    main    test.go:42                  main.func1(#2)
1: runnable
    syscall asm_linux_amd64.s:18        Syscall(0x3, 0x3, 0, 0, 0, 0, 0)
    syscall zsyscall_linux_amd64.go:296 Close(0x3, 0, 0)
    os      file_unix.go:126            (*file).close(#3, 0, 0)
    os      file_unix.go:118            (*File).Close(#13, 0, 0)
    main    test.go:58                  main()
1: syscall [locked]
    runtime asm_amd64.s:1696            goexit()

I'm using Go 1.5.2 installed with gvm under Ubuntu Linux 14.04.3 LTS (x86_64). After some googling i found this issue, but it supposedly fixed in 1.5.2.
Any advice?

@xushiwei
Copy link
Contributor

@RinTohsaka Does it crash in Go 1.6.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants