go-edn / edn

Go implementation of EDN (Extensible Data Notation)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with nil in set

russolsen opened this issue · comments

Hi,

It looks like there is a problem with nils in sets. For example, using the edn_pp program, I get a panic with #{ 1 2 nil 3}:

~/projects/go/edn/examples/edn_pp: ./edn_pp 
1
1
"hello"
"hello"
\c
99
[1 2 3]
[1 2 3]
#{1 2 3}
#{1 2 3}
#{1 2 nil 3}
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0xa0 pc=0x80ef6]

goroutine 1 [running]:
gopkg.in/edn%2ev1.(*Decoder).Decode.func1(0x8202ffe60)
    /Users/russolsen/projects/go/play/src/gopkg.in/edn.v1/decode.go:215 +0x88
gopkg.in/edn%2ev1.(*Decoder).setInterface(0x8202da0e0, 0x0, 0x0)
    /Users/russolsen/projects/go/play/src/gopkg.in/edn.v1/decode.go:844 +0x256
gopkg.in/edn%2ev1.(*Decoder).set(0x8202da0e0, 0x127320, 0x8202ccd30, 0xd4)
    /Users/russolsen/projects/go/play/src/gopkg.in/edn.v1/decode.go:783 +0x2f8
gopkg.in/edn%2ev1.(*Decoder).value(0x8202da0e0, 0x11a300, 0x8202ccd30, 0x16)
    /Users/russolsen/projects/go/play/src/gopkg.in/edn.v1/decode.go:417 +0x245
gopkg.in/edn%2ev1.(*Decoder).Decode(0x8202da0e0, 0x11a300, 0x8202ccd30, 0x0, 0x0)
    /Users/russolsen/projects/go/play/src/gopkg.in/edn.v1/decode.go:231 +0x177
main.main()
    /Users/russolsen/projects/go/edn/examples/edn_pp/edn_pp.go:21 +0x136

Argh, I thought I covered all those edge cases =/

Thanks for the straightforward reproducible case! It was clever of you to use one of the examples to show the problem.

I did some experiments and this also happens with maps: One can test that out with {nil 1} or anything where a key is nil. Internally they are decoded in the same fashion, so presumably fixing one will fix both.

I'll have a look at this during the upcoming days and see if I can find the bug.

Alright, sorry about that. This should now work: You should be able to call go get -u gopkg.in/edn.v1 to get this package working again.

Also, thanks for the report, it is much appreciated =)

Yup, looks like it is fixed. Thanks for the rapid turnaround.

BTW, you might find
https://github.com/cognitect/transit-format/tree/master/examples/0.8/simple
interesting.

In that directory you will find a bunch of edn files with interesting
values in them.

R

On Tue, Jan 26, 2016 at 2:13 PM, hyPiRion notifications@github.com wrote:

Alright, sorry about that. This should now work: You should be able to
call go get -u gopkg.in/edn.v1 to get this package working again.

Also, thanks for the report, it is much appreciated =)


Reply to this email directly or view it on GitHub
#6 (comment).

Russ Olsen
@russolsen
http://www.russolsen.com

Yeah, thanks for the pointers. I'll be sure to take a look and verify that it works as intended on those.