Comments (4)
Same here but for regular Marshal and MarshalIndent: https://go.dev/play/p/c-ddkeoZ7Dr
Go: go version go1.20.1 darwin/amd64
MacOS Ventura 13.2.1: Darwin xxx.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64
package main
import (
"fmt"
"math"
jsoniter "github.com/json-iterator/go"
)
const (
maxFloat64 = float64(math.MaxInt64)
)
func main() {
json := jsoniter.ConfigCompatibleWithStandardLibrary
m := map[string]interface{}{
"test": 42,
"max_int64": math.MaxInt64,
"max_float64": math.MaxFloat64,
"my_max_float": maxFloat64,
}
b, err := json.MarshalIndent(m, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(b))
}
Sharing stacktrace for debugging:
unexpected fault address 0xb01dfacedebac1e
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0xb01dfacedebac1e pc=0x105ec1f]
goroutine 1 [running]:
runtime.throw({0x1125b45?, 0xc00010f440?})
/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0xc000108ad8 sp=0xc000108aa8 pc=0x1031cdd
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:851 +0x28a fp=0xc000108b38 sp=0xc000108ad8 pc=0x1047b6a
aeshashbody()
/usr/local/go/src/runtime/asm_amd64.s:1370 +0x39f fp=0xc000108b40 sp=0xc000108b38 pc=0x105ec1f
runtime.mapiternext(0xc000122400)
/usr/local/go/src/runtime/map.go:936 +0x2eb fp=0xc000108bb0 sp=0xc000108b40 pc=0x100ee6b
runtime.mapiterinit(0x1112160?, 0xc000108c10?, 0x1012865?)
/usr/local/go/src/runtime/map.go:863 +0x236 fp=0xc000108bd0 sp=0xc000108bb0 pc=0x100eb36
reflect.mapiterinit(0x1212460?, 0xc000114f70?, 0x0?)
/usr/local/go/src/runtime/map.go:1375 +0x19 fp=0xc000108bf8 sp=0xc000108bd0 pc=0x105c659
github.com/modern-go/reflect2.(*UnsafeMapType).UnsafeIterate(...)
/Users/user/Coding/Go/pkg/mod/github.com/modern-go/[email protected]/unsafe_map.go:112
github.com/json-iterator/go.(*sortKeysMapEncoder).Encode(0xc00010f4d0, 0xc00011c270, 0xc00011e120)
/Users/user/Coding/Go/src/github.com/fraenky8/jsoniter-go/reflect_map.go:291 +0x225 fp=0xc000108d68 sp=0xc000108bf8 pc=0x10dc6a5
github.com/json-iterator/go.(*onePtrEncoder).Encode(0xc00010c8a0, 0xc00010f170, 0xc000122400?)
/Users/user/Coding/Go/src/github.com/fraenky8/jsoniter-go/reflect.go:219 +0x82 fp=0xc000108da0 sp=0xc000108d68 pc=0x10d4be2
github.com/json-iterator/go.(*Stream).WriteVal(0xc00011e120, {0x1105140, 0xc00010f170})
/Users/user/Coding/Go/src/github.com/fraenky8/jsoniter-go/reflect.go:98 +0x158 fp=0xc000108e10 sp=0xc000108da0 pc=0x10d3ef8
github.com/json-iterator/go.(*frozenConfig).Marshal(0xc0001361e0, {0x1105140, 0xc00010f170})
/Users/user/Coding/Go/src/github.com/fraenky8/jsoniter-go/config.go:299 +0xc9 fp=0xc000108ea8 sp=0xc000108e10 pc=0x10cc729
github.com/json-iterator/go.(*frozenConfig).MarshalIndent(0xc0001360a0, {0x1105140, 0xc00010f170}, {0x0?, 0x60?}, {0x112582a, 0x2})
/Users/user/Coding/Go/src/github.com/fraenky8/jsoniter-go/config.go:320 +0x131 fp=0xc000108f20 sp=0xc000108ea8 pc=0x10cca11
main.main()
/Users/user/Coding/Go/src/github.com/fraenky8/playground/cmd/json/main.go:332 +0x138 fp=0xc000108f80 sp=0xc000108f20 pc=0x10f2738
runtime.main()
/usr/local/go/src/runtime/proc.go:250 +0x207 fp=0xc000108fe0 sp=0xc000108f80 pc=0x1034567
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000108fe8 sp=0xc000108fe0 pc=0x1061701
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00003efb0 sp=0xc00003ef90 pc=0x1034996
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:387
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:305 +0xb0 fp=0xc00003efe0 sp=0xc00003efb0 pc=0x10347d0
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003efe8 sp=0xc00003efe0 pc=0x1061701
created by runtime.init.6
/usr/local/go/src/runtime/proc.go:293 +0x25
goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00003f780 sp=0xc00003f760 pc=0x1034996
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
/usr/local/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc00003f7c8 sp=0xc00003f780 pc=0x1021f4e
runtime.gcenable.func1()
/usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc00003f7e0 sp=0xc00003f7c8 pc=0x10173e6
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003f7e8 sp=0xc00003f7e0 pc=0x1061701
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:178 +0x6b
goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000024070?, 0x114c730?, 0x1?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00003ff70 sp=0xc00003ff50 pc=0x1034996
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x1212020)
/usr/local/go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc00003ffa0 sp=0xc00003ff70 pc=0x101fe53
runtime.bgscavenge(0x0?)
/usr/local/go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc00003ffc8 sp=0xc00003ffa0 pc=0x1020425
runtime.gcenable.func2()
/usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc00003ffe0 sp=0xc00003ffc8 pc=0x1017386
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003ffe8 sp=0xc00003ffe0 pc=0x1061701
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:179 +0xaa
goroutine 17 [finalizer wait]:
runtime.gopark(0x1034d12?, 0x17153c8?, 0x0?, 0x0?, 0xc00003e770?)
/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc00003e628 sp=0xc00003e608 pc=0x1034996
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:193 +0x107 fp=0xc00003e7e0 sp=0xc00003e628 pc=0x1016427
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003e7e8 sp=0xc00003e7e0 pc=0x1061701
created by runtime.createfing
/usr/local/go/src/runtime/mfinal.go:163 +0x45
exit status 2
from go.
go version go1.20.1 windows/amd64 has the same issue
from go.
package main
import (
"fmt"
// jsoniter "github.com/json-iterator/go"
"encoding/json"
)
func main() {
m := map[string]interface{}{
"3": 3,
"1": 1,
"2": 2,
}
// json := jsoniter.ConfigCompatibleWithStandardLibrary
// json := jsoniter.ConfigDefault
b, err := json.Marshal(m)
fmt.Printf(">>> json : %#v\n", b)
fmt.Printf(">>> err : %#v\n", err)
}
If I use "encoding/json", it works
from go.
The same issue happens since last year, modern-go/reflect2#26
Seems like can be fixed by upgrading the Latest jsoniter has the version already.reflect2
version to 1.0.2.
References:
- kubevela/kubevela#3805
- https://github.com/sylr/thanos/blob/ee56d6047acaa803cdddece9cdd792dda629002a/.bingo/prometheus.1.mod#L7
from go.
Related Issues (20)
- Wrong behavior in marshalling invalid UTF-8 byte with EscapeHTML=false
- map[int]int marshalled as \"0:1,2:3\" instead of e.g. {0:1}
- BinaryAsStringExtension panic with escape character HOT 1
- Is json-iterator support "arena" package in golang 1.20 ?
- Logic error of json validation HOT 1
- map bool to string failed
- Add security policy
- jsoniter.Marshal makes ordered maps unordered HOT 2
- 还有人维护么 HOT 3
- Proposal: grow buffers more efficiently
- Bug: incompatibility with standard lib
- Bug: panic when jsoniter.Marshal map[string]string HOT 2
- concurrent map iteration and map write
- dx suggestion
- Bug: incompatibility with standard lib map instead of nil
- m2 macbook pro fatal error: fault HOT 2
- Bug: Incompatibility with standard lib (omitempty w/ custom marshaler)
- Bug: Cannot Unmarshal null fields to UUID HOT 1
- Jsoniterator
- Remove the dependency on github.com/modern-go/reflect2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go.