Skip to content
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

panic: runtime error: index out of range #29

Open
cioban opened this issue Sep 12, 2018 · 2 comments
Open

panic: runtime error: index out of range #29

cioban opened this issue Sep 12, 2018 · 2 comments

Comments

@cioban
Copy link

cioban commented Sep 12, 2018

Hi

I'm trying to run the server example in order to just print the messages received on the port.
My intent is verify all messages sent by a software called M32Edit (from Behringer).
However my server application is crashing after I start my client application (the M32Edit).
I'm receiving the error: panic: runtime error: index out of range

Here is my code:

package main

import (
    "github.com/hypebeast/go-osc/osc"
    "fmt"
)
func main() {
  addr := "0.0.0.0:10023"
  fmt.Println("Starting server at:", addr)
  server := &osc.Server{Addr: addr}

  fmt.Println(server)
  
  /*
  server.Handle("/message/address", func(msg *osc.Message) {
    osc.PrintMessage(msg)
  })
  */

  server.ListenAndServe()
}

Here is the output:

Starting server at: 0.0.0.0:10023
&{0.0.0.0:10023 <nil> 0s}
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/hypebeast/go-osc/osc.readArguments(0xc0000c8030, 0xc0000cc000, 0xc00004bdb8, 0x8, 0x0)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:719 +0x143d
github.com/hypebeast/go-osc/osc.readMessage(0xc0000cc000, 0xc00004bdb8, 0xc0000ce000, 0x1, 0x1000)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:701 +0xd3
github.com/hypebeast/go-osc/osc.readPacket(0xc0000cc000, 0xc00004bdb8, 0x8, 0xc0000ce000, 0x1000, 0x1000, 0xc0000c8000)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:628 +0x116
github.com/hypebeast/go-osc/osc.(*Server).readFromConnection(0xc00000c0c0, 0x56bd60, 0xc00000e038, 0x56ade0, 0xc000074630, 0x0, 0x0)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:602 +0x230
github.com/hypebeast/go-osc/osc.(*Server).Serve(0xc00000c0c0, 0x56bd60, 0xc00000e038, 0xd, 0x56bd60)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:559 +0x4a
github.com/hypebeast/go-osc/osc.(*Server).ListenAndServe(0xc00000c0c0, 0x1, 0x1)
	<suppressed>/Dropbox/sandbox/go/gocode/src/github.com/hypebeast/go-osc/osc/osc.go:551 +0xa0
main.main()
	<suppressed>/Dropbox/sandbox/go/gocode/src/osc_server/main.go:27 +0x121
exit status 2

I believe this is an issue with the library.
Can you please help me to solve this issue?

@porjo
Copy link

porjo commented Mar 25, 2019

if typetags[0] != ',' { is being run where typetags is an empty string - this produces the index out of range error. This is a bug in the library, and additional checks should be added.

@dylannorthrup
Copy link

if typetags[0] != ',' { is being run where typetags is an empty string - this produces the index out of range error. This is a bug in the library, and additional checks should be added.

In the current code, it does a length check on typetags before it tries to check its values.

	if len(typetags) == 0 {
		return nil
	}

@cioban, is this still an issue with the current version of the library?

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

3 participants