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

Marshal抛panic #7

Closed
LyricTian opened this issue Feb 3, 2017 · 1 comment
Closed

Marshal抛panic #7

LyricTian opened this issue Feb 3, 2017 · 1 comment

Comments

@LyricTian
Copy link

测试代码

package json_test

import "testing"
import "github.com/json-iterator/go"

func TestJsoniter(t *testing.T) {
	v := struct {
		VV  map[string]interface{}
		Foo string
	}{
		VV: map[string]interface{}{
			"foo": "bar",
		},
		Foo: "foo",
	}

	buf, err := jsoniter.Marshal(v)
	if err != nil {
		t.Error(err.Error())
		return
	}
	t.Log(string(buf))
}
=== RUN   TestJsoniter
unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x9a94]

goroutine 6 [running]:
runtime.throw(0x15f277, 0x5)
	/usr/local/go/src/runtime/panic.go:566 +0x95 fp=0xc42004a9b8 sp=0xc42004a998
runtime.sigpanic()
	/usr/local/go/src/runtime/sigpanic_unix.go:27 +0x288 fp=0xc42004aa10 sp=0xc42004a9b8
runtime.mapiternext(0xc420018420)
	/usr/local/go/src/runtime/hashmap.go:731 +0xe4 fp=0xc42004aab8 sp=0xc42004aa10
runtime.mapiterinit(0x1375a0, 0xc420010440, 0xc420018420)
	/usr/local/go/src/runtime/hashmap.go:679 +0x1c1 fp=0xc42004aaf8 sp=0xc42004aab8
reflect.mapiterinit(0x1375a0, 0xc420010440, 0x15)
	/usr/local/go/src/runtime/hashmap.go:1029 +0x54 fp=0xc42004ab28 sp=0xc42004aaf8
reflect.Value.MapKeys(0x1375a0, 0xc420010440, 0x15, 0xc420010440, 0x15, 0x13200983e8)
	/usr/local/go/src/reflect/value.go:1074 +0xc0 fp=0xc42004abd0 sp=0xc42004ab28
github.com/json-iterator/go.(*mapInterfaceEncoder).encode(0xc42000ab40, 0xc420010440, 0xc420014230)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect.go:255 +0xba fp=0xc42004ac88 sp=0xc42004abd0
github.com/json-iterator/go.(*structFieldEncoder).encode(0xc42000e750, 0xc420010440, 0xc420014230)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect_object.go:402 +0x97 fp=0xc42004ad08 sp=0xc42004ac88
github.com/json-iterator/go.(*structEncoder).encode(0xc420010460, 0xc420010440, 0xc420014230)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect_object.go:420 +0x54 fp=0xc42004ad50 sp=0xc42004ad08
github.com/json-iterator/go.WriteToStream(0x13dfa0, 0xc420010440, 0xc420014230, 0x1fd6e0, 0xc420010460)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect.go:34 +0xfa fp=0xc42004ad90 sp=0xc42004ad50
github.com/json-iterator/go.(*structEncoder).encodeInterface(0xc420010460, 0x13dfa0, 0xc420010440, 0xc420014230)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect_object.go:429 +0x55 fp=0xc42004adc8 sp=0xc42004ad90
github.com/json-iterator/go.(*Stream).WriteVal(0xc420014230, 0x13dfa0, 0xc420010440)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_reflect.go:312 +0xa8 fp=0xc42004ae38 sp=0xc42004adc8
github.com/json-iterator/go.Marshal(0x13dfa0, 0xc420010440, 0xc420010440, 0x13dfa0, 0xc420010440, 0x0, 0x0)
	/Users/lyric/go/src/github.com/json-iterator/go/feature_adapter.go:74 +0x144 fp=0xc42004aea0 sp=0xc42004ae38
temp.com/json-sample_test.TestJsoniter(0xc42008e180)
	/Users/lyric/go/src/temp.com/json-sample/map_test.go:17 +0x162 fp=0xc42004af78 sp=0xc42004aea0
testing.tRunner(0xc42008e180, 0x171588)
	/usr/local/go/src/testing/testing.go:610 +0x81 fp=0xc42004afa0 sp=0xc42004af78
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc42004afa8 sp=0xc42004afa0
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:646 +0x2ec

goroutine 1 [chan receive]:
testing.(*T).Run(0xc42008e0c0, 0x1604bd, 0xc, 0x171588, 0x58a01)
	/usr/local/go/src/testing/testing.go:647 +0x316
testing.RunTests.func1(0xc42008e0c0)
	/usr/local/go/src/testing/testing.go:793 +0x6d
testing.tRunner(0xc42008e0c0, 0xc420045e20)
	/usr/local/go/src/testing/testing.go:610 +0x81
testing.RunTests(0x171070, 0x20c160, 0x2, 0x2, 0xe27b)
	/usr/local/go/src/testing/testing.go:799 +0x319
testing.(*M).Run(0xc420045ee8, 0xc420045f00)
	/usr/local/go/src/testing/testing.go:743 +0x85
main.main()
	temp.com/json-sample/_test/_testmain.go:64 +0xc6
exit status 2
FAIL	temp.com/json-sample	0.010s
Error: Tests failed.
@taowen
Copy link
Contributor

taowen commented Feb 3, 2017

6880076

should have fixed it

@taowen taowen closed this as completed Feb 3, 2017
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