Skip to content

v1.15.0: concurrent Unmarshal can crash with "found pointer to free object" in jitdec.decodeTypedPointer #912

Description

@thrasher-

Describe the bug

Initially spotted here: https://github.com/thrasher-/gocryptotrader/actions/runs/22474422306/job/65098292110#step:11:101

github.com/bytedance/sonic v1.15.0 crashes under concurrent Unmarshal with runtime memory corruption.
The crash reproduces in a pure standalone Go repro that uses only Sonic + stdlib + local JSON fixtures.

Test repo can be found here: sonic-standalone.tar.gz

To Reproduce

Steps to reproduce the behavior:

  1. Download/clone the standalone repro and cd into it.
  2. Run:
    go run ./main.go -workers 64 -iters 800
  3. Wait a few seconds while concurrent decode runs.
  4. See error (fatal error: found pointer to free object, sometimes other runtime corruption errors).

Expected behavior

Concurrent decode should complete without runtime corruption, panic, or segfault.

Screenshots

N/A (terminal crash output only)

Sonic version:

github.com/bytedance/sonic v1.15.0

Environment:

The output of go env.

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/thrasher/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/thrasher/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4114862870=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/thrasher/dev/gocryptotrader/go.mod'
GOMODCACHE='/home/thrasher/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/thrasher/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/thrasher/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.0'
GOWORK=''
PKG_CONFIG='pkg-config'

Additional context

Crash signatures include:

  • fatal error: found pointer to free object
  • runtime: marked free object in span ...
  • stack frames repeatedly through:
    • github.com/bytedance/sonic/internal/decoder/jitdec.decodeTypedPointer
    • github.com/bytedance/sonic.frozenConfig.UnmarshalFromString (sonic.go:118)

This reproduces frequently in the standalone repro and does not depend on any external API calls during the failing decode stage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions