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

x/mobile: building 2 independent xcframeworks for iOS Simulator, but crash when app start up #50594

Open
pipi32167 opened this issue Jan 13, 2022 · 5 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@pipi32167
Copy link

pipi32167 commented Jan 13, 2022

What version of Go are you using (go version)?

$ go version
go version go1.17.6 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/x/Library/Caches/go-build"
GOENV="/Users/x/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/x/.gvm/pkgsets/go1.17.6/global/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/x/.gvm/pkgsets/go1.17.6/global"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/Users/x/.gvm/gos/go1.17.6"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/x/.gvm/gos/go1.17.6/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/private/tmp/golang-crash-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vd/lrhd0qbn1t56jjs5ml_81_w00000gp/T/go-build4026723300=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Building 2 independent xcframeworks for iOS App to use.

gomobile bind -tags test1 -target=ios -o build/golang_crash_test1.xcframework ./crash
gomobile bind -tags test2 -target=ios -o build/golang_crash_test2.xcframework ./crash

And then use the xcframeworks in the Xcode project

What did you expect to see?

The iOS program is able to run properly.

What did you see instead?

The iOS program running crash with the callstack:

#0	0x000000010e814d55 in debugCall65536 ()
#1	0x000000010ed76899 in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const ()
#2	0x000000010ed92941 in invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const ()
#3	0x000000010ed8be09 in invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const ()
#4	0x000000010ed8af5f in dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const ()
#5	0x000000010ed8bb93 in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const ()
#6	0x000000010ed923a2 in dyld3::MachOAnalyzer::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, unsigned char const*, bool&) block_pointer) const ()
#7	0x000000010ed925e4 in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const ()
#8	0x000000010ed767cc in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const ()
#9	0x000000010ed76958 in dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const ()
#10	0x000000010ed769f6 in dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const ()
#11	0x000000010ed852d8 in dyld4::APIs::runAllInitializersForMain() ()
#12	0x000000010ed69920 in dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) ()
#13	0x000000010ed69d3f in _dyld_sim_prepare ()
#14	0x00000001145fcb24 in dyld4::prepareSim(dyld4::RuntimeState&, char const*) ()
#15	0x00000001145fb6de in dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*) ()
#16	0x00000001145fb4b4 in start ()
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jan 13, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jan 13, 2022
@dr2chase
Copy link
Contributor

dr2chase commented Jan 13, 2022

@hyangah can you give this a look?

@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 13, 2022
@ydnar
Copy link

ydnar commented Jan 31, 2022

@pipi32167 are both frameworks built from the same Go package? Does it crash if the two XCFrameworks are built from different Go packages?

@CoderHarry
Copy link

CoderHarry commented Feb 5, 2022

how to solve it? I build 2 xcframeworks also crash

@pipi32167
Copy link
Author

pipi32167 commented Feb 16, 2022

how to solve it? I build 2 xcframeworks also crash

I just merge 2 xcframeworks into 1.

@OEA
Copy link

OEA commented Aug 29, 2022

I had also same problem. We have 2 independent go library and If I bind two libraries into two different xcframework, It causes a crash.

fatal error: minpc or maxpc invalid
runtime: panic before malloc heap initialized

runtime stack:
runtime.throw({0x102eafb8c?, 0x0?})
	/usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x17bbbee60 sp=0x17bbbee30 pc=0x10294a840
runtime.moduledataverify1(0x1034a2f20)
	/usr/local/go/src/runtime/symtab.go:636 +0x41c fp=0x17bbbef40 sp=0x17bbbee60 pc=0x102966ffc
runtime.moduledataverify(...)
	/usr/local/go/src/runtime/symtab.go:593
runtime.schedinit()
	/usr/local/go/src/runtime/proc.go:691 +0x40 fp=0x17bbbefa0 sp=0x17bbbef40 pc=0x10294dee0
runtime.rt0_go()
	/usr/local/go/src/runtime/asm_arm64.s:86 +0xd0 fp=0x17bbbefd0 sp=0x17bbbefa0 pc=0x102975c20

I used same sys package same dependencies but never succeed.

Merging 2 frameworks into 1 is solving problem but I think it needs further investigation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants