modern-go / reflect2 Goto Github PK
View Code? Open in Web Editor NEWreflect api without runtime reflect.Value cost
License: Apache License 2.0
reflect api without runtime reflect.Value cost
License: Apache License 2.0
Hi there.
This might be an unusual "issue" beeing reported.
There has been a security incident in codecov.io with the bash-uploader script (see [1] for details) which potentially exposed secrets to 3rd parties.
It seems you are using the referenced bash uploader in your .travis.yml file. I wanted to draw your attention to this incident in case you missed it.
It would be great if you could verify that no code has been altered and check the impact of this security incident on your repository.
Regards,
Robert
When i deserialized a json string, it size is about 40KB. and in benchmark case , I found the UnsafeSetIndex method cost much memory, it's about 40% memory, and the gc can't collection immediately. and this problem trouble me a lot
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x4616bf]
goroutine 40 [running]:
runtime.throw({0x90159d?, 0x8?})
/usr/local/go/src/runtime/panic.go:992 +0x71 fp=0xc0000bb2f0 sp=0xc0000bb2c0 pc=0x435051
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:825 +0x305 fp=0xc0000bb340 sp=0xc0000bb2f0 pc=0x44a545
aeshashbody()
/usr/local/go/src/runtime/asm_amd64.s:1343 +0x39f fp=0xc0000bb348 sp=0xc0000bb340 pc=0x4616bf
runtime.mapiternext(0xc0002ace40)
/usr/local/go/src/runtime/map.go:934 +0x2cb fp=0xc0000bb3b8 sp=0xc0000bb348 pc=0x410f0b
runtime.mapiterinit(0x1?, 0x1b?, 0x10?)
/usr/local/go/src/runtime/map.go:861 +0x228 fp=0xc0000bb3d8 sp=0xc0000bb3b8 pc=0x410be8
reflect.mapiterinit(0x861b00?, 0x40b9b5?, 0x87ca98?)
/usr/local/go/src/runtime/map.go:1373 +0x19 fp=0xc0000bb400 sp=0xc0000bb3d8 pc=0x45e539
github.com/modern-go/reflect2.(*UnsafeMapType).UnsafeIterate(...)
/root/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_map.go:112
github.com/json-iterator/go.(*mapEncoder).Encode(0xc0003cca50, 0xc0002acbe0, 0xc000281680)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_map.go:257 +0x21c fp=0xc0000bb4b0 sp=0xc0000bb400 pc=0x58cddc
github.com/json-iterator/go.(*structFieldEncoder).Encode(0xc0003ccbd0, 0x839d14?, 0xc000281680)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_struct_encoder.go:110 +0x56 fp=0xc0000bb528 sp=0xc0000bb4b0 pc=0x59a6f6
github.com/json-iterator/go.(*structEncoder).Encode(0xc0003ccc30, 0x0?, 0xc000281680)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_struct_encoder.go:158 +0x652 fp=0xc0000bb600 sp=0xc0000bb528 pc=0x59aff2
github.com/json-iterator/go.(*OptionalEncoder).Encode(0xc00011e280?, 0x0?, 0x0?)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_optional.go:74 +0xa4 fp=0xc0000bb650 sp=0xc0000bb600 pc=0x592724
github.com/json-iterator/go.(*onePtrEncoder).Encode(0xc0003b7330, 0xc0002acbc0, 0xc0003cc3f0?)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:219 +0x82 fp=0xc0000bb688 sp=0xc0000bb650 pc=0x585e02
github.com/json-iterator/go.(*Stream).WriteVal(0xc000281680, {0x895760, 0xc0002acbc0})
/root/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:98 +0x158 fp=0xc0000bb6f8 sp=0xc0000bb688 pc=0x585118
github.com/json-iterator/go.(*frozenConfig).Marshal(0xc00011e280, {0x895760, 0xc0002acbc0})
/root/go/pkg/mod/github.com/json-iterator/[email protected]/config.go:299 +0xc9 fp=0xc0000bb790 sp=0xc0000bb6f8 pc=0x57d809
github.com/json-iterator/go.Marshal(...)
/root/go/pkg/mod/github.com/json-iterator/[email protected]/adapter.go:34
github.asiainfo-sec.com/ZSP-SDP/aisdp-common/aisdp-rocketmq/rocketmq-client-go/v2/internal/remote.(*jsonCodec).encodeHeader(0xc0000bb838?, 0x4104fd?)
/root/go/pkg/mod/github.asiainfo-sec.com/!z!s!p-!s!d!p/aisdp-common/[email protected]/rocketmq-client-go/v2/internal/remote/codec.go:281 +0x33 fp=0xc0000bb7b8 sp=0xc0000bb790 pc=0x7bda93
Hello!
I have tried to build the docker and faced with an issue of undefined reference.
I found a discussion about the same issue here:
https://www.mail-archive.com/[email protected]/msg31266.html
Latest versions of docker, containerd and kubernets use reflect2 package.
Is it possible to support compiling with gccgo in reflect2?
go version
)?$ go version go version go1.13 gollvm LLVM 10.0.0svn linux/amd64
or
$ go version go version go1.10.3 gccgo (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0 linux/amd64
$ uname -o -m x86_64 GNU/Linux
$ git clone https://github.com/docker/docker-ce.git $ cd docker-ce $ git checkout v19.03.4 $ cd components $ mkdir -p .gopath/src/github.com/docker $ export GOPATH=`pwd`/.gopath:~/go $ ln -sf `pwd`/cli .gopath/src/github.com/docker/cli $ cd .gopath/src/github.com/docker/cli/
Clean compiling.
$ go build -tags 'static_build' github.com/docker/cli/cmd/docker # github.com/docker/cli/cmd/docker .gopath/src/github.com/docker/cli/vendor/github.com/modern-go/reflect2/type_map.go:34: error: undefined reference to 'reflect.typelinks' .gopath/src/github.com/docker/cli/vendor/github.com/modern-go/reflect2/type_map.go:66: error: undefined reference to 'reflect.typelinks' .gopath/src/github.com/docker/cli/vendor/github.com/modern-go/reflect2/type_map.go:70: error: undefined reference to 'reflect.resolveTypeOff'
code as following failed:
var m interface{}=[]int{1,2}
slType:=reflect2.TypeOf(m).(reflect2.SliceType)
slType.LengthOf(m) //<--here i can't use &m
Show my code.
1、utils package
It define the student struct,like that:
package utils
import (
"fmt"
)
type Student struct {
Name string
}
func (s *Student) PrintName() {
fmt.Println(s.Name)
}
2、Use the Student
The main function use reflect2 to find the student type,like that:
package main
import (
_ "example/testreflect/utils"
"fmt"
"github.com/modern-go/reflect2"
)
func main() {
tp := reflect2.TypeByPackageName("example/testreflect/utils", "Student")
fmt.Println(tp)
}
the output is :
<nil>
it cant find the student.
3、change the way to use the Student
package main
import (
"example/testreflect/utils"
"fmt"
"github.com/modern-go/reflect2"
)
func main() {
fmt.Println(utils.Student{})
tp := reflect2.TypeByPackageName("example/testreflect/utils", "Student")
fmt.Println(tp)
}
and the output is :
{}
utils.Student
It Works now.
So it confuse me....can anyone help?
Hello!
I have tried to compile my own project which has a dependency of "reflect2" package with the most recent gccgo but failed with a message of "undefined reference". Is it possible to make it compile using gccgo?
Details shown below:
The most recent commit (commit 333559e1834b0c1840d283d79220bf121d704022
).
go version
)?go version go1.16.3 gccgo (GCC) 11.0.1 20210423 (prerelease) linux/amd64
Additionally, gccgo --version
tells:
gccgo (GCC) 11.0.1 20210423 (prerelease)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat /etc/issue
Arch Linux \r (\l)
$ uname -a
Linux 5.11.16-arch1-1 #1 SMP PREEMPT Wed, 21 Apr 2021 17:22:13 +0000 x86_64 GNU/Linux
Trying to build some code that depends on this package.
The code successfully compiles.
/usr/bin/ld: /home/lam/.cache/go-build/fd/fd4891df5167b3e9b000124e5b53c9fccc0f3aa55647fda5583b97f1c087b5d9-d(_go_.o): in function `github_0com_1modern_x2dgo_1reflect2.UnsafeSliceType.UnsafeMakeSlice':
/home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_slice.go:78: undefined reference to `reflect.unsafe_NewArray'
/usr/bin/ld: /home/lam/.cache/go-build/fd/fd4891df5167b3e9b000124e5b53c9fccc0f3aa55647fda5583b97f1c087b5d9-d(_go_.o): in function `github_0com_1modern_x2dgo_1reflect2.unsafeType.UnsafeNew':
/home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: undefined reference to `reflect.unsafe_New'
/usr/bin/ld: /home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: undefined reference to `reflect.unsafe_New'
/usr/bin/ld: /home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: undefined reference to `reflect.unsafe_New'
/usr/bin/ld: /home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: undefined reference to `reflect.unsafe_New'
/usr/bin/ld: /home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: undefined reference to `reflect.unsafe_New'
/usr/bin/ld: /home/lam/.cache/go-build/fd/fd4891df5167b3e9b000124e5b53c9fccc0f3aa55647fda5583b97f1c087b5d9-d(_go_.o):/home/lam/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_type.go:48: more undefined references to `reflect.unsafe_New' follow
collect2: error: ld returned 1 exit status
Thanks for your patient and effort.
Hi All,
I am running jobs on travis-ci and found that jobs are failing for go1.8.X. Below are the logs
$ git clone --depth=50 --branch=master https://github.com/kishorkunal-raj/reflect2.git kishorkunal-raj/reflect2
$ travis_export_go 1.8.x github.com/kishorkunal-raj/reflect2
0.01s3.98s$ travis_setup_go
go version go1.8.7 linux/amd64
$ export GOPATH="/home/travis/gopath"
$ export PATH="/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.8.7.linux.amd64/bin:/home/travis/bin:/home/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbrew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/gems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.3/bin:/usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.rvm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin"
$ export GO111MODULE="auto"
$ gimme version
v1.5.4
$ go version
go version go1.8.7 linux/amd64
go.env
$ go env
before_install.1
1.02s$ go get -t -v ./...
before_install.2
11.36s$ go get -t -v github.com/modern-go/reflect2-tests/...
install
0.08s$ travis_install_go_dependencies 1.8.x -v
3.16s$ ./test.sh
warning: no packages being tested depend on github.com/modern-go/reflect2
ok github.com/modern-go/reflect2-tests 0.004s coverage: 12.2% of statements in github.com/modern-go/reflect2
warning: no packages being tested depend on github.com/modern-go/reflect2
ok github.com/modern-go/reflect2-tests/test15 0.003s coverage: 6.0% of statements in github.com/modern-go/reflect2
warning: no packages being tested depend on github.com/modern-go/reflect2
../../stretchr/testify/assert/assertions.go:1703: undefined: errors.Is
../../stretchr/testify/assert/assertions.go:1726: undefined: errors.Is
../../stretchr/testify/assert/assertions.go:1749: undefined: errors.As
../../stretchr/testify/assert/assertions.go:1766: undefined: errors.Unwrap
../../stretchr/testify/assert/assertions.go:1770: undefined: errors.Unwrap
FAIL github.com/modern-go/reflect2-tests/tests [build failed]
The command "./test.sh" exited with 2.
Done. Your build exited with 1.
Please help me out to fix it.
Good day,
https://codecov.io/bash recently outputted a security issue. Details can be found at https://about.codecov.io/security-update/
The following file and code are impacted. Please follow the recommended actions in the link above to secure your env and code integrity.
file: .travis.yml
Code:
after_success:
bash <(curl -s https://codecov.io/bash)
Hi All,
I found if I use any reflect2 function in my app, I can't use go build --compiler=gccgo to compile it.
It will return error like that:
go build --compiler=gccgo map_1.go
/tmp/go-build467403193/b023/pkg.a(go.o): In function github_com_modern_go_reflect2.loadGo15Types': /usr/lib/go-1.10/src/github.com/modern-go/reflect2/type_map.go:42: undefined reference to
reflect.typelinks'
/tmp/go-build467403193/b023/pkg.a(go.o): In function github_com_modern_go_reflect2.loadGo17Types': /usr/lib/go-1.10/src/github.com/modern-go/reflect2/type_map.go:74: undefined reference to
reflect.typelinks'
/usr/lib/go-1.10/src/github.com/modern-go/reflect2/type_map.go:78: undefined reference to `reflect.resolveTypeOff'
collect2: error: ld returned 1 exit status
Any idea to fix it?
Thanks
Zhang Chen
The NoEscape function in reflect2.go is causing go vet failure, and there is no way to suppress go vet failures. I see that is being used by countlog library. Is there any way to fix this?
Many packages do not build, using gollvm, if they depend on reflect2 package.
So I am opening an issue, to track down bugs.
$ go version && go env
go version go1.15rc2 gollvm LLVM 12.0.0git linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/oceanfish81/.cache/go-build"
GOENV="/home/oceanfish81/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/oceanfish81/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/oceanfish81/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/tools"
GCCGO="/usr/local/bin/llvm-goc"
AR="ar"
CC="/usr/bin/clang"
CXX="/usr/bin/clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build330690378=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
$go get -v -x -u github.com/modern-go/reflect2
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
git config remote.origin.url
github.com/modern-go/reflect2 (download)
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
git pull --ff-only
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
git submodule update --init --recursive
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
git show-ref
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
git submodule update --init --recursive
cd /home/oceanfish81/go/src/github.com/modern-go/concurrent
git config remote.origin.url
github.com/modern-go/concurrent (download)
cd /home/oceanfish81/go/src/github.com/modern-go/concurrent
git pull --ff-only
cd /home/oceanfish81/go/src/github.com/modern-go/concurrent
git submodule update --init --recursive
cd /home/oceanfish81/go/src/github.com/modern-go/concurrent
git show-ref
cd /home/oceanfish81/go/src/github.com/modern-go/concurrent
git submodule update --init --recursive
WORK=/tmp/go-build972636668
github.com/modern-go/reflect2
mkdir -p $WORK/b001/
cd $WORK
/usr/local/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
mkdir -p $WORK/b001/importcfgroot/github.com/modern-go
ln -s /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/libconcurrent.a $WORK/b001/importcfgroot/github.com/modern-go/libconcurrent.a
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
/usr/local/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=github.com/modern-go/reflect2 -o $WORK/b001/go.o -I $WORK/b001/importcfgroot ./go_above_17.go ./go_above_19.go ./reflect2.go ./reflect2_kind.go ./safe_field.go ./safe_map.go ./safe_slice.go ./safe_struct.go ./safe_type.go ./unsafe_array.go ./unsafe_eface.go ./unsafe_field.go ./unsafe_iface.go ./unsafe_link.go ./unsafe_map.go ./unsafe_ptr.go ./unsafe_slice.go ./unsafe_struct.go ./unsafe_type.go
/usr/local/bin/llvm-goc -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/reflect2_amd64.o -D GOOS_linux -D GOARCH_amd64 -D GOPKGPATH=github.x2ecom..z2fmodern..z2dgo..z2freflect2 -m64 ./reflect2_amd64.s
/usr/local/bin/llvm-goc -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/relfect2_mips64x.o -D GOOS_linux -D GOARCH_amd64 -D GOPKGPATH=github.x2ecom..z2fmodern..z2dgo..z2freflect2 -m64 ./relfect2_mips64x.s
/usr/local/bin/llvm-goc -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/relfect2_mipsx.o -D GOOS_linux -D GOARCH_amd64 -D GOPKGPATH=github.x2ecom..z2fmodern..z2dgo..z2freflect2 -m64 ./relfect2_mipsx.s
/usr/local/bin/llvm-goc -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/relfect2_ppc64x.o -D GOOS_linux -D GOARCH_amd64 -D GOPKGPATH=github.x2ecom..z2fmodern..z2dgo..z2freflect2 -m64 ./relfect2_ppc64x.s
echo ' .section .go.buildid,"e"' >> $WORK/b001/_buildid.s
echo ' .byte 0x49,0x72,0x39,0x5f,0x74,0x4b,0x30,0x4d' >> $WORK/b001/_buildid.s
echo ' .byte 0x44,0x4b,0x76,0x4f,0x64,0x4a,0x6b,0x66' >> $WORK/b001/_buildid.s
echo ' .byte 0x6c,0x6a,0x66,0x36,0x2f,0x49,0x72,0x39' >> $WORK/b001/_buildid.s
echo ' .byte 0x5f,0x74,0x4b,0x30,0x4d,0x44,0x4b,0x76' >> $WORK/b001/_buildid.s
echo ' .byte 0x4f,0x64,0x4a,0x6b,0x66,0x6c,0x6a,0x66' >> $WORK/b001/_buildid.s
echo ' .byte 0x36' >> $WORK/b001/_buildid.s
echo ' .section .note.GNU-stack,"",@progbits' >> $WORK/b001/_buildid.s
echo ' .section .note.GNU-split-stack,"",@progbits' >> $WORK/b001/_buildid.s
echo '' >> $WORK/b001/_buildid.s
/usr/local/bin/llvm-goc -xassembler-with-cpp -I $WORK/b001/ -c -o $WORK/b001/_buildid.o -D GOOS_linux -D GOARCH_amd64 -D GOPKGPATH=github.x2ecom..z2fmodern..z2dgo..z2freflect2 -m64 $WORK/b001/_buildid.s
ar rcD $WORK/b001/pkg.a $WORK/b001/go.o $WORK/b001/reflect2_amd64.o $WORK/b001/relfect2_mips64x.o $WORK/b001/relfect2_mipsx.o $WORK/b001/relfect2_ppc64x.o $WORK/b001/_buildid.o
/usr/local/tools/buildid -w $WORK/b001/pkg.a # internal
cp $WORK/b001/pkg.a /home/oceanfish81/.cache/go-build/bb/bb1ccdbe2d1e5c3e297ea920c00ece48719ed58e080bc6fa128bf3c94de20540-d # internal
mkdir -p /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/
mv $WORK/b001/pkg.a /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/libreflect2.a
rm -r $WORK/b001/
$ go build -v -x -i github.com/modern-go/reflect2
WORK=/tmp/go-build819572343$ go install github.com/modern-go/reflect2
$ cd ~/go/src/github.com/modern-go/reflect2
$ go build -i -v -x *.go
WORK=/tmp/go-build381158134
command-line-arguments
mkdir -p $WORK/b001/
cd $WORK
/usr/local/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
mkdir -p $WORK/b001/importcfgroot/github.com/modern-go
ln -s /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/libconcurrent.a $WORK/b001/importcfgroot/github.com/modern-go/libconcurrent.a
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
/usr/local/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=command-line-arguments -fgo-relative-import-path=_/home/oceanfish81/go/src/github.com/modern-go/reflect2 -o $WORK/b001/go.o -I $WORK/b001/importcfgroot ./go_above_17.go ./go_above_19.go ./go_below_17.go ./go_below_19.go ./reflect2.go ./reflect2_kind.go ./safe_field.go ./safe_map.go ./safe_slice.go ./safe_struct.go ./safe_type.go ./type_map.go ./unsafe_array.go ./unsafe_eface.go ./unsafe_field.go ./unsafe_iface.go ./unsafe_link.go ./unsafe_map.go ./unsafe_ptr.go ./unsafe_slice.go ./unsafe_struct.go ./unsafe_type.gocommand-line-arguments
./go_below_17.go:7:1: error: redefinition of 'resolveTypeOff'
./go_above_17.go:8:1: note: previous definition of 'resolveTypeOff' was here
./go_below_19.go:10:1: error: redefinition of 'makemap'
./go_above_19.go:10:1: note: previous definition of 'makemap' was here
./go_below_19.go:12:1: error: redefinition of 'makeMapWithSize'
./go_above_19.go:12:1: note: previous definition of 'makeMapWithSize' was here
./go_below_19.go:13:9: error: not enough arguments
$ go build -i -v -x *.go
WORK=/tmp/go-build381158134
command-line-arguments
mkdir -p $WORK/b001/
cd $WORK
/usr/local/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
mkdir -p $WORK/b001/importcfgroot/github.com/modern-go
ln -s /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/libconcurrent.a $WORK/b001/importcfgroot/github.com/modern-go/libconcurrent.a
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
/usr/local/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=command-line-arguments -fgo-relative-import-path=_/home/oceanfish81/go/src/github.com/modern-go/reflect2 -o $WORK/b001/go.o -I $WORK/b001/importcfgroot ./go_above_17.go ./go_above_19.go ./go_below_17.go ./go_below_19.go ./reflect2.go ./reflect2_kind.go ./safe_field.go ./safe_map.go ./safe_slice.go ./safe_struct.go ./safe_type.go ./type_map.go ./unsafe_array.go ./unsafe_eface.go ./unsafe_field.go ./unsafe_iface.go ./unsafe_link.go ./unsafe_map.go ./unsafe_ptr.go ./unsafe_slice.go ./unsafe_struct.go ./unsafe_type.gocommand-line-arguments
./go_below_17.go:7:1: error: redefinition of 'resolveTypeOff'
./go_above_17.go:8:1: note: previous definition of 'resolveTypeOff' was here
./go_below_19.go:10:1: error: redefinition of 'makemap'
./go_above_19.go:10:1: note: previous definition of 'makemap' was here
./go_below_19.go:12:1: error: redefinition of 'makeMapWithSize'
./go_above_19.go:12:1: note: previous definition of 'makeMapWithSize' was here
./go_below_19.go:13:9: error: not enough arguments
$ go build reflect2.go
command-line-arguments
./reflect2.go:168:14: error: use of undefined type 'safeType'
./reflect2.go:145:22: error: reference to undefined name 'unpackEFace'
./reflect2.go:157:22: error: reference to undefined name 'unpackEFace'
./reflect2.go:172:12: error: use of undefined type 'safeStructType'
./reflect2.go:172:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:174:10: error: reference to undefined name 'newUnsafeStructType'
./reflect2.go:177:12: error: use of undefined type 'safeSliceType'
./reflect2.go:177:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:179:10: error: reference to undefined name 'newUnsafeArrayType'
./reflect2.go:177:12: error: use of undefined type 'safeSliceType'
./reflect2.go:182:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:184:10: error: reference to undefined name 'newUnsafeSliceType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:187:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:189:10: error: reference to undefined name 'newUnsafeMapType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:192:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:194:10: error: reference to undefined name 'newUnsafePtrType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:197:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:200:11: error: reference to undefined name 'newUnsafeEFaceType'
./reflect2.go:202:10: error: reference to undefined name 'newUnsafeIFaceType'
./reflect2.go:205:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:207:10: error: reference to undefined name 'newUnsafeType'
./reflect2.go:231:9: error: reference to undefined name 'unpackEFace'
./reflect2.go:235:17: error: reference to undefined name 'unpackEFace'
./reflect2.go:242:9: error: reference to undefined name 'unpackEFace'
$ go build -i -v -x reflect2.go
WORK=/tmp/go-build178738731
command-line-arguments
mkdir -p $WORK/b001/
cd $WORK
/usr/local/bin/llvm-goc -fgo-importcfg=/dev/null -c -x c - -o /dev/null || true
mkdir -p $WORK/b001/importcfgroot/github.com/modern-go
ln -s /home/oceanfish81/go/pkg/gccgo_linux_amd64/github.com/modern-go/libconcurrent.a $WORK/b001/importcfgroot/github.com/modern-go/libconcurrent.a
cd /home/oceanfish81/go/src/github.com/modern-go/reflect2
/usr/local/bin/llvm-goc -c -O2 -g -m64 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -fgo-pkgpath=command-line-arguments -fgo-relative-import-path=_/home/oceanfish81/go/src/github.com/modern-go/reflect2 -o $WORK/b001/go.o -I $WORK/b001/importcfgroot ./reflect2.gocommand-line-arguments
./reflect2.go:168:14: error: use of undefined type 'safeType'
./reflect2.go:145:22: error: reference to undefined name 'unpackEFace'
./reflect2.go:157:22: error: reference to undefined name 'unpackEFace'
./reflect2.go:172:12: error: use of undefined type 'safeStructType'
./reflect2.go:172:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:174:10: error: reference to undefined name 'newUnsafeStructType'
./reflect2.go:177:12: error: use of undefined type 'safeSliceType'
./reflect2.go:177:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:179:10: error: reference to undefined name 'newUnsafeArrayType'
./reflect2.go:177:12: error: use of undefined type 'safeSliceType'
./reflect2.go:182:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:184:10: error: reference to undefined name 'newUnsafeSliceType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:187:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:189:10: error: reference to undefined name 'newUnsafeMapType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:192:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:194:10: error: reference to undefined name 'newUnsafePtrType'
./reflect2.go:187:12: error: use of undefined type 'safeMapType'
./reflect2.go:197:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:200:11: error: reference to undefined name 'newUnsafeEFaceType'
./reflect2.go:202:10: error: reference to undefined name 'newUnsafeIFaceType'
./reflect2.go:205:11: error: incompatible type for return value 1 (type has no methods)
./reflect2.go:207:10: error: reference to undefined name 'newUnsafeType'
./reflect2.go:231:9: error: reference to undefined name 'unpackEFace'
./reflect2.go:235:17: error: reference to undefined name 'unpackEFace'
./reflect2.go:242:9: error: reference to undefined name 'unpackEFace'
In a CI run of our project, we hit the following panic (using the kubernetes client to list some custom resources):
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]
goroutine 165 [running]:
github.com/modern-go/reflect2.(*frozenConfig).wrapType(0xc00036d150, 0xc000666a00, 0xc0001914a0, 0x0, 0x0)
/go/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:168 +0x6f
github.com/modern-go/reflect2.(*frozenConfig).Type2(0xc00036d150, 0xc000666a00, 0xc0001914a0, 0x1, 0xc000b6e6e0)
/go/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:161 +0xa1
github.com/modern-go/reflect2.(*UnsafeStructField).Type(0xc000c08000, 0xe0, 0x22900fb)
/go/pkg/mod/github.com/modern-go/[email protected]/unsafe_field.go:37 +0x45
github.com/json-iterator/go.describeStruct(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x7f0300023d98)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_extension.go:349 +0xab2
github.com/json-iterator/go.decoderOfStruct(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0xc000b87998, 0xc0003d2f00)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x22900f0, 0x1)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:124 +0x78
github.com/json-iterator/go.describeStruct(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x7f030000be34)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_extension.go:380 +0xa4f
github.com/json-iterator/go.decoderOfStruct(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0xc0009e7e28, 0x212e0c0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x22900f0, 0x1)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:124 +0x78
github.com/json-iterator/go.decoderOfSlice(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_slice.go:12 +0x105
github.com/json-iterator/go._createDecoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0xc0009e7e18, 0xc0003d2f00)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:180 +0x4ff
github.com/json-iterator/go.createDecoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x22900f0, 0x1)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:124 +0x78
github.com/json-iterator/go.describeStruct(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x1fbd6)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_extension.go:380 +0xa4f
github.com/json-iterator/go.decoderOfStruct(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0xc0009e7dc8, 0xc0003d2f00)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:124 +0x78
github.com/json-iterator/go.(*frozenConfig).DecoderOf(0xc00049a1e0, 0x2855800, 0xc000bf0e70, 0x2855800, 0xc000bf0e70)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:114 +0x111
github.com/json-iterator/go.(*Iterator).ReadVal(0xc0007cac60, 0x2199a00, 0xc000344070)
/go/pkg/mod/github.com/json-iterator/[email protected]/reflect.go:72 +0x1ce
github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc00049a1e0, 0xc000ba6c00, 0x2d7, 0x600, 0x2199a00, 0xc000344070, 0x0, 0x0)
/go/pkg/mod/github.com/json-iterator/[email protected]/config.go:348 +0xd2
k8s.io/apimachinery/pkg/runtime/serializer/json.(*Serializer).Decode(0xc0000d4050, 0xc000ba6c00, 0x2d7, 0x600, 0x0, 0x27cb780, 0xc000344070, 0x3d, 0x1, 0x0, ...)
/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/serializer/json/json.go:263 +0x600
k8s.io/apimachinery/pkg/runtime.WithoutVersionDecoder.Decode(0x27b2c20, 0xc0000d4050, 0xc000ba6c00, 0x2d7, 0x600, 0x0, 0x27cb780, 0xc000344070, 0xc0008c7600, 0xc0008c7500, ...)
/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/helper.go:252 +0x97
k8s.io/client-go/rest.Result.Into(0xc000ba6c00, 0x2d7, 0x600, 0xc000483c20, 0x10, 0x0, 0x0, 0xc8, 0x27b5820, 0xc000bf4360, ...)
/go/pkg/mod/k8s.io/[email protected]/rest/request.go:1182 +0xba
...
We've only seen the panic once so far despite running many CI runs daily.
Reported in json-iter too; not sure where it belongs: json-iterator/go#462
Runtime package used isn't imported in runtime.go file
Please fix it as fast as you can :)
The commit: golang/go@1b2d794
was landed, so reflect.mapiterinit
will change in go1.18.
See also: golang/go#48238
go version is 1.15.5
I got panic when I use jsoniter.Unmarshal,the input object type is
struct {
Data json.RawMessage `json:"data"`
Extra map[string]interface{} `json:"extra"`
}{}
recover from panic: err=runtime error: invalid memory address or nil pointer dereference stack=goroutine 24838623 [running]:
runtime/debug.Stack(0xc0002283f0, 0x0, 0xdf23865)
/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
xxxxxxxxx(0xdf2b129, 0x6, 0xdf21b8d, 0x4, 0xc0c5217400)
xxxxx:244 +0x30a
panic(0xd39d2a0, 0x14396cd0)
/usr/local/go/src/runtime/panic.go:969 +0x1b9
sync.(*Map).Store(0xc0ca8046c0, 0xd1a7520, 0xc0c53a5298, 0xdd28c00, 0xc0c53ec700)
/usr/local/go/src/sync/map.go:151 +0x365
github.com/modern-go/reflect2.(*frozenConfig).Type2(0xc000206ba0, 0xecd8b40, 0xd0a0f20, 0x0, 0x0)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:162 +0x10e
github.com/modern-go/reflect2.(*frozenConfig).TypeOf(0xc000206ba0, 0xd0a0f20, 0x0, 0xc0c3cee4b8, 0x4f3614d)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:149 +0xb7
github.com/modern-go/reflect2.TypeOf(...)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:211
github.com/modern-go/reflect2.TypeOfPtr(...)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/[email protected]/reflect2.go:215
github.com/json-iterator/go.(*frozenConfig).escapeHTML(0xc0c53ad180, 0xc0c53f3470)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/[email protected]/config.go:271 +0x46
github.com/json-iterator/go.Config.Froze(0x0, 0x1010100, 0x0, 0x0, 0x100, 0xc0c53f3300, 0x30)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/[email protected]/config.go:155 +0x2e7
github.com/json-iterator/go.Config.frozeWithCacheReuse(0x0, 0x1010100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0xe944ea0)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/[email protected]/config.go:174 +0x114
github.com/json-iterator/go.(*Decoder).UseNumber(...)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/[email protected]/adapter.go:103
A number of files in the repo are named like relfect
(e.g., relfect2_386.s
), a possible typo of reflect
. But, enough of them are named this way that I'm not sure it's an accident. 🤔
Can relfect*
be renamed to reflect*
? If so I'd be happy to send a PR.
Hi,
I can't find reflect2.TypeByName
func in go 1.18 !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.