id3-go icon indicating copy to clipboard operation
id3-go copied to clipboard

Having issues with id3-go on go1.7.1 darwin/amd64

Open david4shure opened this issue 8 years ago • 0 comments

Hello there,

I used to do active development on a go 1.5.X setup on my macbook. I recently upgraded to go 1.7.1 for darwin and I am seeing runtime errors when trying to run some code that uses id3-go. The following function is fairly simple, it takes in a file extension as a string, and a path as a string, and recursively walks through the directory tree starting at the path, and returns a slice of SongFile{} representing an MP3 file.


type SongFile struct {
        RawArtist string `json:"raw_artist"`
        RawAlbum  string `json:"raw_album"`
        RawTitle  string `json:"raw_title"`
        Path      string `json:"path"`
        FileName  string `json:"filename"`
        AlbumArt  string `json"album_art"`
}

func checkExt(ext string, path string) []SongFile {
        var files []SongFile
        filepath.Walk(path, func(p string, f os.FileInfo, _ error) error {
                if !f.IsDir() {
                        r, err := regexp.MatchString(ext, f.Name())
                        if err == nil && r {
                                mp3File, err := id3.Open(p)
                                defer mp3File.Close()
                                if err == nil {
                                        // Sometimes the strings come out bad with null bytes, so I do a string replace
                                        artist := strings.Replace(mp3File.Artist(), "\u0000", "", -1)
                                        album := strings.Replace(mp3File.Album(), "\u0000", "", -1)
                                        title := strings.Replace(mp3File.Title(), "\u0000", "", -1)

                                        if artist == "" {
                                                artist = "Unknown Artist"
                                        }
                                        if album == "" {
                                                album = "Unknown Album"
                                        }
                                        if title == "" {
                                                title = "Unknown Title"
                                        }

                                        sf := SongFile{Path: p, FileName: f.Name(), RawArtist: artist, RawAlbum: album, RawTitle: title}
                                        files = append(files, sf)
                                } else {
                                        fmt.Println(err.Error())
                                        fmt.Println("! " + p + " !")
                                }
                        }
                }
                return nil
        })
        return files
}

The exact stack trace I am seeing when I call this function is as follows

panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 1 [running]:
panic(0x428d620, 0xc42027e5f0)
    /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/djimenez/iconv-go.(*Converter).Convert(0xc420019360, 0xc42027e5a8, 0x5, 0x8, 0xc42027e5b0, 0xa, 0xa, 0x40415bb, 0x10, 0x4277ca0, ...)
    /Users/david.shure/go/src/github.com/djimenez/iconv-go/converter.go:83 +0x55c
github.com/djimenez/iconv-go.(*Converter).ConvertString(0xc420019360, 0xc4204b34b8, 0x5, 0x5, 0xc4204b34b8, 0x5, 0x4013418)
    /Users/david.shure/go/src/github.com/djimenez/iconv-go/converter.go:123 +0x184
github.com/mikkyang/id3-go/encodedbytes.(*Reader).ReadRestString(0xc4204b3528, 0xc42000cf00, 0x6, 0x0, 0x0, 0x6)
    /Users/david.shure/go/src/github.com/mikkyang/id3-go/encodedbytes/reader.go:69 +0xaa
github.com/mikkyang/id3-go/v2.ParseTextFrame(0x42daac4, 0x4, 0x42e4613, 0x22, 0x42ff9b0, 0x600000000, 0x0, 0xc42027e59a, 0x6, 0x6, ...)
    /Users/david.shure/go/src/github.com/mikkyang/id3-go/v2/frame.go:233 +0x152
github.com/mikkyang/id3-go/v2.ParseV23Frame(0x4401540, 0xc420472118, 0xc420472118, 0x4401540)
    /Users/david.shure/go/src/github.com/mikkyang/id3-go/v2/id3v23.go:150 +0x389
github.com/mikkyang/id3-go/v2.ParseTag(0x4404040, 0xc420472118, 0x2)
    /Users/david.shure/go/src/github.com/mikkyang/id3-go/v2/id3v2.go:74 +0x11b
github.com/mikkyang/id3-go.Open(0xc42011ebd0, 0x2f, 0xc42011ebf1, 0xe, 0x476e701)
    /Users/david.shure/go/src/github.com/mikkyang/id3-go/id3.go:58 +0xd0
main.checkExt.func1(0xc42011ebd0, 0x2f, 0x4406680, 0xc42025edd0, 0x0, 0x0, 0x0, 0x0)
    /Users/david.shure/stash/griffon/server/griffon.go:94 +0x152
path/filepath.walk(0xc42011ebd0, 0x2f, 0x4406680, 0xc42025edd0, 0xc4200cc8e0, 0x0, 0x0)
    /usr/local/go/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc42030e8a0, 0x20, 0x4406680, 0xc42025ed00, 0xc4200cc8e0, 0x0, 0x0)
    /usr/local/go/src/path/filepath/path.go:376 +0x344
path/filepath.walk(0xc42030e760, 0x1e, 0x4406680, 0xc42025eb60, 0xc4200cc8e0, 0x0, 0x0)
    /usr/local/go/src/path/filepath/path.go:376 +0x344
path/filepath.walk(0xc4202a3600, 0x1c, 0x4406680, 0xc420076820, 0xc4200cc8e0, 0x0, 0x0)
    /usr/local/go/src/path/filepath/path.go:376 +0x344
path/filepath.walk(0x7fff5fbff58c, 0x13, 0x4406680, 0xc420077a00, 0xc4200cc8e0, 0x0, 0x1)
    /usr/local/go/src/path/filepath/path.go:376 +0x344
path/filepath.Walk(0x7fff5fbff58c, 0x13, 0xc4200cc8e0, 0x1c, 0x42ff9b0)
    /usr/local/go/src/path/filepath/path.go:398 +0xd5
main.checkExt(0x42dad2d, 0x5, 0x7fff5fbff58c, 0x13, 0x8, 0x42ff9b8, 0x42da786)
    /Users/david.shure/stash/griffon/server/griffon.go:121 +0xce
main.main()
    /Users/david.shure/stash/griffon/server/griffon.go:139 +0x153

After I first encountered this issue, I deleted the source code of id3-go from my $GOPATH, and re-ran go get github.com/mikkyang/id3-go but this hasn't fixed the issue. Please let me know if you need any additional information from my environment. Any information on this would be greatly appreciated. Thanks!

david4shure avatar Oct 27 '16 01:10 david4shure