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

ParseMessage panic: assignment to entry in nil map quickfix v0.6.0 #390

Open
keith6014 opened this issue Nov 21, 2019 · 1 comment
Open

Comments

@keith6014
Copy link

keith6014 commented Nov 21, 2019

I have some simple code to read a FIX message and I keep getting a ParseMessage Panic.
I placed the byte array in comments so there aren't any rendering issues

package main

import (
	"bytes"
	"fmt"

	"github.com/quickfixgo/quickfix"
)

func main() {

	rawMsg := bytes.NewBufferString("8=FIX.4.29=10435=D34=249=TW52=20140515-19:49:56.65956=ISLD11=10021=140=154=155=TSLA60=00010101-00:00:00.00010=039")
	fmt.Println(rawMsg.Bytes())
//[56 61 70 73 88 46 52 46 50 1 57 61 49 48 52 1 51 53 61 68 1 51 52 61 50 1 52 57 61 84 87 1 53 50 61 50 48 49 52 48 53 49 53 45 49 57 58 52 57 58 53 54 46 54 53 57 1 53 54 61 73 83 76 68 1 49 49 61 49 48 48 1 50 49 61 49 1 52 48 61 49 1 53 52 61 49 1 53 53 61 84 83 76 65 1 54 48 61 48 48 48 49 48 49 48 49 45 48 48 58 48 48 58 48 48 46 48 48 48 1 49 48 61 48 51 57 1]

	var msg quickfix.Message
	err := quickfix.ParseMessage(&msg, rawMsg)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("--", msg)
}

The error message is
panic: assignment to entry in nil map

panic: assignment to entry in nil map
  
goroutine 1 [running]:
github.com/quickfixgo/quickfix.(*FieldMap).add(...)
        /Users/ranj/go/pkg/mod/github.com/quickfixgo/[email protected]/field_map.go:208
github.com/quickfixgo/quickfix.ParseMessageWithDataDictionary(0xc000042de8, 0xc0000b0630, 0x0, 0x0, 0x1, 0x171)
        /Users/ranj/go/pkg/mod/github.com/quickfixgo/[email protected]/message.go:158 +0x201
github.com/quickfixgo/quickfix.ParseMessage(...)
        /Users/ranj/go/pkg/mod/github.com/quickfixgo/[email protected]/message.go:120
main.main()
        /Users/ranj/go-fixtest/main.go:16 +0x185
exit status 2

My go.mod looks like this


go 1.12

require (
	github.com/mattn/go-sqlite3 v1.13.0 // indirect
	github.com/quickfixgo/quickfix v0.6.0
	github.com/shopspring/decimal v0.0.0-20191009025716-f1972eb1d1f5 // indirect
	github.com/stretchr/testify v1.4.0
)
@linmaosong2018
Copy link
Contributor

Looks like this is already fixed in a newer version by the lines below:

quickfix/message.go

Lines 160 to 162 in 76e0003

if fieldCount == 0 {
return parseError{OrigError: fmt.Sprintf("No Fields detected in %s", string(rawBytes))}
}

Indeed, running the same test code against newest quickfix produces the output below:

[56 61 70 73 88 46 52 46 50 57 61 49 48 52 51 53 61 68 51 52 61 50 52 57 61 84 87 53 50 61 50 48 49 52 48 53 49 53 45 49 57 58 52 57 58 53 54 46 54 53 57 53 54 61 73 83 76 68 49 49 61 49 48 48 50 49 61 49 52 48 61 49 53 52 61 49 53 53 61 84 83 76 65 54 48 61 48 48 48 49 48 49 48 49 45 48 48 58 48 48 58 48 48 46 48 48 48 49 48 61 48 51 57]
error parsing message: No Fields detected in 8=FIX.4.29=10435=D34=249=TW52=20140515-19:49:56.65956=ISLD11=10021=140=154=155=TSLA60=00010101-00:00:00.00010=039
-- {{{map[] {[] <nil>}}} {{map[] {[] <nil>}}} {{map[] {[] <nil>}}} 0001-01-01 00:00:00 +0000 UTC 0xc000092ab0 [] [] false}

I would suggest upgrading to a newer version.

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

2 participants