krig/go-sox

Error when open many files

jerson opened this issue · 3 comments

func ExtractorSoxFaster(filename string) (map[string]string, error) {

	if !sox.Init() {
		return nil, errors.New("Failed to initialize SoX")
	}
	defer sox.Quit()

	in := sox.OpenRead(filename) //error here 
	if in == nil {
		return nil, errors.New("Failed to open input file")
	}
	defer in.Release()

// more here...
}

[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fbe145f6900 pc=0x7fbe145f6900]

runtime stack:
runtime.throw(0x8d0ecf, 0x2a)
	/usr/local/go/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:274 +0x2db

goroutine 89 [syscall, locked to thread]:
runtime.cgocall(0x7d9610, 0xc420159450, 0x1)
	/usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc420159420 sp=0xc4201593e0
app.com/utils/vendor/github.com/krig/go-sox._Cfunc_sox_open_read(0x7fbdf80059b0, 0x0, 0x0, 0x0, 0x0)
	app.com/utils/vendor/github.com/krig/go-sox/_obj/_cgo_gotypes.go:791 +0x4e fp=0xc420159450 sp=0xc420159420
app.com/utils/vendor/github.com/krig/go-sox.OpenRead(0xc420281680, 0x32, 0x8bf4f3)
	/srv/go/src/app.com/utils/vendor/github.com/krig/go-sox/sox.go:352 +0x8d fp=0xc420159498 sp=0xc420159450
app.com/utils/modules/scripts/waveform.ExtractorSoxFaster(0xc420281680, 0x32, 0x0, 0x0, 0x0)
	/srv/go/src/app.com/utils/modules/scripts/waveform/extractor.go:165 +0x110 fp=0xc4201595b8 sp=0xc420159498
app.com/utils/modules/extractor.GetSongWaveform(0xc420422a60, 0x17, 0x0, 0x0, 0xc420367050, 0x6, 0xc4202815c0, 0x31, 0xc420281600, 0x37, ...)
	/srv/go/src/app.com/utils/modules/extractor/waveform.go:11 +0x70 fp=0xc420159668 sp=0xc4201595b8
app.com/utils/commands.SongWaveformUpdate(0xc420124568, 0x6, 0x0, 0x0, 0x0)
	/srv/go/src/app.com/utils/commands/song.go:545 +0x3e5 fp=0xc4201598c0 sp=0xc420159668
main.main.func1(0xc420124568, 0x6, 0x0, 0x0, 0x0, 0x0)
	/srv/go/src/app.com/utils/cmd/job/main.go:45 +0x287 fp=0xc420159960 sp=0xc4201598c0
runtime.call64(0xc420132630, 0x8fd148, 0xc420242270, 0x1000000030)
	/usr/local/go/src/runtime/asm_amd64.s:515 +0x48 fp=0xc4201599b0 sp=0xc420159960
reflect.Value.call(0x839cc0, 0x8fd148, 0x13, 0x8bf553, 0x4, 0xc4201f6b00, 0x1, 0x1, 0xc420493d68, 0xc420493d60, ...)
	/usr/local/go/src/reflect/value.go:434 +0x91f fp=0xc420159cf8 sp=0xc4201599b0
reflect.Value.Call(0x839cc0, 0x8fd148, 0x13, 0xc4201f6b00, 0x1, 0x1, 0x0, 0x0, 0xc420014180)
	/usr/local/go/src/reflect/value.go:302 +0xa4 fp=0xc420159d60 sp=0xc420159cf8
app.com/utils/vendor/github.com/RichardKnop/machinery/v1.TryCall(0x839cc0, 0x8fd148, 0x13, 0xc4201f6b00, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:249 +0xf1 fp=0xc420159db8 sp=0xc420159d60
app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Process(0xc42011a3c0, 0xc42008ee70, 0x105, 0x83ee40)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:91 +0x42c fp=0xc420159eb0 sp=0xc420159db8
app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consumeOne(0xc42009f900, 0xc420114360, 0x105, 0x105, 0xcefa40, 0xc42011a3c0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:219 +0x1af fp=0xc420159f60 sp=0xc420159eb0
app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume.func2(0xc42009f900, 0xc420114360, 0x105, 0x105, 0xcefa40, 0xc42011a3c0, 0x0, 0xc42006eba0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:248 +0x61 fp=0xc420159fa0 sp=0xc420159f60
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420159fa8 sp=0xc420159fa0
created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:253 +0x233

goroutine 1 [chan receive]:
app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch(0xc42011a3c0, 0xc42011a3c0, 0xc42004bf48)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:50 +0x654
main.main()
	/srv/go/src/app.com/utils/cmd/job/main.go:238 +0xa4a

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 5 [select]:
app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).consume(0xc42009f900, 0xc42006eb40, 0xcefa40, 0xc42011a3c0, 0x0, 0x0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:237 +0x2da
app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming(0xc42009f900, 0x8bf723, 0x4, 0xcefa40, 0xc42011a3c0, 0x0, 0x0, 0x0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:142 +0x28a
app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch.func1(0xcf70a0, 0xc42009f900, 0xc42011a3c0, 0xc42006e960)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:39 +0x74
created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1.(*Worker).Launch
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/worker.go:48 +0x612

goroutine 6 [IO wait]:
net.runtime_pollWait(0x7fbe1f5ad158, 0x72, 0x6)
	/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc420013568, 0x72, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc420013568, 0xc42011f000, 0x1000)
	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc420013500, 0xc42011f000, 0x1000, 0x1000, 0x0, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42000e0a8, 0xc42011f000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:181 +0x70
bufio.(*Reader).fill(0xc42006ec00)
	/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).ReadSlice(0xc42006ec00, 0xa, 0xc420047bd0, 0x0, 0x8fd220, 0xc420047be0, 0xc420047bd0)
	/usr/local/go/src/bufio/bufio.go:338 +0xbb
app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).readLine(0xc42009fa40, 0x0, 0x2c, 0x8bf171, 0x0, 0x0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:341 +0x49
app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).readReply(0xc42009fa40, 0x0, 0x0, 0xc4201f68e0, 0x2)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:414 +0x43
app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*conn).Do(0xc42009fa40, 0x8bf91d, 0x5, 0xc4201f68e0, 0x2, 0x2, 0x822260, 0xc4201244c0, 0xc420047f70, 0xc4201244c0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/conn.go:562 +0x11f
app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis.(*pooledConnection).Do(0xc42011a5e0, 0x8bf91d, 0x5, 0xc4201f68e0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/vendor/github.com/garyburd/redigo/redis/pool.go:369 +0xa3
app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming.func1(0xc42009f900, 0xc42006eb40)
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:96 +0x2b6
created by app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers.(*RedisBroker).StartConsuming
	/srv/go/src/app.com/utils/vendor/github.com/RichardKnop/machinery/v1/brokers/redis.go:140 +0x258

goroutine 12 [IO wait]:
net.runtime_pollWait(0x7fbe1f5ace58, 0x72, 0xa)
	/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc420142688, 0x72, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc420142688, 0xc420118c00, 0x400)
	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc420142620, 0xc420118c00, 0x400, 0x400, 0x0, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42000e0b8, 0xc420118c00, 0x400, 0x400, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:181 +0x70
crypto/tls.(*block).readFromUntil(0xc420117830, 0x7fbe1f5ad2d8, 0xc42000e0b8, 0x5, 0xc42000e0b8, 0x46b200)
	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
crypto/tls.(*Conn).readRecord(0xc420099180, 0x8fdd17, 0xc4200992a0, 0x42abc6)
	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
crypto/tls.(*Conn).Read(0xc420099180, 0xc42044e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
bufio.(*Reader).Read(0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0xc42019ec60, 0xc42019ec60, 0x413292)
	/usr/local/go/src/bufio/bufio.go:213 +0x312
io.ReadAtLeast(0xceeb40, 0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0x9, 0xc420389920, 0xc42019ed00, 0x8bfa00)
	/usr/local/go/src/io/io.go:307 +0xa9
io.ReadFull(0xceeb40, 0xc42006e8a0, 0xc4200706b8, 0x9, 0x9, 0xc420367001, 0xc420367000, 0x0)
	/usr/local/go/src/io/io.go:325 +0x58
net/http.http2readFrameHeader(0xc4200706b8, 0x9, 0x9, 0xceeb40, 0xc42006e8a0, 0x0, 0xc400000000, 0xc420597400, 0x10a)
	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
net/http.(*http2Framer).ReadFrame(0xc420070680, 0xc420213a70, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
net/http.(*http2clientConnReadLoop).run(0xc42019efb0, 0x8fd3b0, 0xc420480fb0)
	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
net/http.(*http2ClientConn).readLoop(0xc420001ba0)
	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
created by net/http.(*http2Transport).newClientConn
	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728

goroutine 47 [IO wait]:
net.runtime_pollWait(0x7fbe1f5acd98, 0x72, 0xb)
	/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4202fe308, 0x72, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc4202fe308, 0xc4201ee000, 0x800)
	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc4202fe2a0, 0xc4201ee000, 0x800, 0x800, 0x0, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42013c008, 0xc4201ee000, 0x800, 0x800, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:181 +0x70
crypto/tls.(*block).readFromUntil(0xc4201160c0, 0x7fbe1f5ad2d8, 0xc42013c008, 0x5, 0xc42013c008, 0x46b203)
	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
crypto/tls.(*Conn).readRecord(0xc4202ca000, 0x8fdd17, 0xc4202ca120, 0x42abc6)
	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
crypto/tls.(*Conn).Read(0xc4202ca000, 0xc420416000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
bufio.(*Reader).Read(0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0x40e062, 0x8c1948, 0x8c1736)
	/usr/local/go/src/bufio/bufio.go:213 +0x312
io.ReadAtLeast(0xceeb40, 0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0x9, 0xc42006fa40, 0xc420038d00, 0x8bfa00)
	/usr/local/go/src/io/io.go:307 +0xa9
io.ReadFull(0xceeb40, 0xc420388c60, 0xc42013e2a8, 0x9, 0x9, 0xc420349001, 0xc420349010, 0x0)
	/usr/local/go/src/io/io.go:325 +0x58
net/http.http2readFrameHeader(0xc42013e2a8, 0x9, 0x9, 0xceeb40, 0xc420388c60, 0x0, 0xc400000000, 0xc42012ec80, 0x3ee)
	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
net/http.(*http2Framer).ReadFrame(0xc42013e270, 0xc4201f33e0, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
net/http.(*http2clientConnReadLoop).run(0xc420038fb0, 0x8fd3b0, 0xc42047dfb0)
	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
net/http.(*http2ClientConn).readLoop(0xc4202b04e0)
	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
created by net/http.(*http2Transport).newClientConn
	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728

goroutine 87 [IO wait]:
net.runtime_pollWait(0x7fbe1f5accd8, 0x72, 0xc)
	/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4202fe848, 0x72, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc4202fe848, 0xc42044b000, 0x1000)
	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc4202fe7e0, 0xc42044b000, 0x1000, 0x1000, 0x0, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42013c088, 0xc42044b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:181 +0x70
crypto/tls.(*block).readFromUntil(0xc420017e60, 0x7fbe1f5ad2d8, 0xc42013c088, 0x5, 0xc42013c088, 0xc420063040)
	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
crypto/tls.(*Conn).readRecord(0xc42020ce00, 0x8fdd17, 0xc42020cf20, 0xc420019368)
	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
crypto/tls.(*Conn).Read(0xc42020ce00, 0xc4204d3000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
bufio.(*Reader).Read(0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x0, 0x0, 0x100000000000000)
	/usr/local/go/src/bufio/bufio.go:213 +0x312
io.ReadAtLeast(0xceeb40, 0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x9, 0x42abc6, 0x1000, 0x11)
	/usr/local/go/src/io/io.go:307 +0xa9
io.ReadFull(0xceeb40, 0xc420389ce0, 0xc42013eed8, 0x9, 0x9, 0x3, 0xc420019350, 0xc420019300)
	/usr/local/go/src/io/io.go:325 +0x58
net/http.http2readFrameHeader(0xc42013eed8, 0x9, 0x9, 0xceeb40, 0xc420389ce0, 0x0, 0x0, 0x8fddc0, 0xc42048dda8)
	/usr/local/go/src/net/http/h2_bundle.go:781 +0x7b
net/http.(*http2Framer).ReadFrame(0xc42013eea0, 0xc4204d0ee0, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/http/h2_bundle.go:1008 +0xa4
net/http.(*http2clientConnReadLoop).run(0xc42048dfb0, 0x8fd3b0, 0xc42047dfb0)
	/usr/local/go/src/net/http/h2_bundle.go:6626 +0x88
net/http.(*http2ClientConn).readLoop(0xc4202b1ba0)
	/usr/local/go/src/net/http/h2_bundle.go:6555 +0xa6
created by net/http.(*http2Transport).newClientConn
	/usr/local/go/src/net/http/h2_bundle.go:5880 +0x728

goroutine 72 [IO wait]:
net.runtime_pollWait(0x7fbe1f5ad218, 0x72, 0x4)
	/usr/local/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc4202fe458, 0x72, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc4202fe458, 0xc420109000, 0x800)
	/usr/local/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc4202fe3f0, 0xc420109000, 0x800, 0x800, 0x0, 0xcf0e80, 0xced520)
	/usr/local/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc42000e160, 0xc420109000, 0x800, 0x800, 0x0, 0x0, 0x0)
	/usr/local/go/src/net/net.go:181 +0x70
crypto/tls.(*block).readFromUntil(0xc4201f20c0, 0x7fbe1f5ad2d8, 0xc42000e160, 0x5, 0xc42000e160, 0x28)
	/usr/local/go/src/crypto/tls/conn.go:488 +0x98
crypto/tls.(*Conn).readRecord(0xc420098380, 0x8fdd17, 0xc4200984a0, 0x4537b0)
	/usr/local/go/src/crypto/tls/conn.go:590 +0xc4
crypto/tls.(*Conn).Read(0xc420098380, 0xc4201d0000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/local/go/src/crypto/tls/conn.go:1134 +0x11d
net/http.(*persistConn).Read(0xc42012b0e0, 0xc4201d0000, 0x1000, 0x1000, 0x5, 0x451a80, 0xc42014b080)
	/usr/local/go/src/net/http/transport.go:1316 +0x14b
bufio.(*Reader).fill(0xc42014af00)
	/usr/local/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc42014af00, 0x1, 0xc42019cbe5, 0xc4201df201, 0x4, 0xc42014af60, 0x0)
	/usr/local/go/src/bufio/bufio.go:129 +0x67
net/http.(*persistConn).readLoop(0xc42012b0e0)
	/usr/local/go/src/net/http/transport.go:1474 +0x196
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1117 +0xa35

goroutine 73 [select]:
net/http.(*persistConn).writeLoop(0xc42012b0e0)
	/usr/local/go/src/net/http/transport.go:1704 +0x43a
created by net/http.(*Transport).dialConn
	/usr/local/go/src/net/http/transport.go:1118 +0xa5a

goroutine 101 [runnable]:
net/http.(*http2clientStream).awaitRequestCancel(0xc420597400, 0xc42006c500)
	/usr/local/go/src/net/http/h2_bundle.go:5576
created by net/http.(*http2clientConnReadLoop).handleResponse
	/usr/local/go/src/net/http/h2_bundle.go:6811 +0x6f7

I solved this by not init the sox each time I open a file.

krig commented

Good point, try moving the calls to Init and Quit out of the function, and only calling them once.

thanks @quangbuule it work for me :D