senseyeio / roger

Golang RServe client. Use R from Go
MIT License
272 stars 34 forks source link

panic when creating a list using bool or NA values #26

Open APILLSBURY opened 8 years ago

APILLSBURY commented 8 years ago

When sending a command to create a list I'm getting a panic: runtime error: index out of range with certain combinations of values. What I've observed is the following. 1) Creating a list of strings, ints, and floats in any combination works. Ex: list(int=1,string='s',float=0.5)

2) If the list has a bool or NA as the last value, the correct result is returned but there is a Warning: Error whilst constructing vector: Abruptly reached end of buffer outputted. Ex: list(int=1,string='s',float=0.5,bool=TRUE) Ex: list(var=NA)

3) If the list contains a bool or NA value with anything else following it, a panic happens. Ex: list(int=1,string='s',float=0.5,bool=TRUE,anything='this causes a panic') Ex: list(var1=NA,var2=1)

Here is the full stack trace for the panic:

panic: runtime error: index out of range

goroutine 1 [running]:
roger/sexp.getLength(0xc820431484, 0x38, 0x38, 0x29, 0x1, 0x420460, 0x0, 0x0)
    roger/sexp/factory.go:25 +0x12f
roger/sexp.parseReturningOffset(0xc820431484, 0x38, 0x38, 0x29, 0x0, 0x0, 0x0, 0x0, 0x0)
    roger/sexp/factory.go:35 +0xa0
roger/sexp.parseVector(0x437840, 0xc820436960, 0xc820431484, 0x38, 0x38, 0x29, 0x38, 0x0, 0x0, 0x0, ...)
    roger/sexp/xt-vector.go:37 +0xba
roger/sexp.parseReturningOffset(0xc820431484, 0x38, 0x38, 0x20, 0x0, 0x0, 0x8591d, 0x0, 0x0)
    roger/sexp/factory.go:80 +0x752
roger/sexp.Parse(0xc820431484, 0x38, 0x38, 0x0, 0x0, 0x0, 0x0, 0x0)
    roger/sexp/factory.go:13 +0x61
roger.(*packet).GetResultObject(0xc820436930, 0x0, 0x0, 0x0, 0x0)
    roger/packet.go:77 +0x31e
dareid commented 8 years ago

Thanks for the detailed issue! I will try to look into this issue this weekend. I fear the list parsing is not correct and this probably relates to #24.

APILLSBURY commented 8 years ago

Thanks. Let me know if you need any more info from me.

harryrose commented 8 years ago

Incorrectly closed by my previous commit. Reopening, as NA handling still needs work.

andrei-m commented 8 years ago

Any word on NA? I am interested in using it, but running into this issue.

dareid commented 8 years ago

I have began working on support for NAs in lists, however it is tricky to do in a backwards compatible manner. Hopefully I will get time to finish it off shortly. I am very open to pull requests for this