Closed
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version
)?
go version devel +0e392c6 Thu May 26 09:27:08 2016 +0800 windows/amd64 - What operating system and processor architecture are you using (
go env
)?
set GOARCH=arm
set GOARM=7
set GOOS=android
set CGO_ENABLED=1 - What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
armstack.go
package main
/*
typedef struct {
int x,y,z;
int a,b,c,d,e,f,g,h,i,j,k;
} S1;
typedef struct {
int a,b,c;
S1 x,y,z[30];
} S2;
extern void cgoCallback(S1* s1,S2* s2,int cnt);
*/
import "C"
import (
"log"
)
type S1 C.S1
type S2 C.S2
//export cgoCallback
func cgoCallback(s1 *S1, s2 *S2, cnt C.int) {
cnt++
log.Println("cgoCallback1:", int(cnt), s1, s2)
if cnt < 500 {
s1 := &S1{}
s2 := &S2{}
cgoCallback(s1, s2, cnt)
}
}
func main() {
log.Println(".")
}
main.c
#include <stdio.h>
#include <stdlib.h>
#include "libarmstack.h"
int main(int argc, char** argv) {
S1 o1 = {0};
S2 o2 = {0};
S1* s1= &o1;
S2* s2= &o2;
cgoCallback(s1,s2,0);
cgoCallback(s1,s2,0);
//cgoCallback(s1,s2,0);
return 0;
}
go build -buildmode c-shared -o libarmstack.so armstack.go
gcc -marm main.c -o armstack -L. -larmstack
push to android 4.4 phone, then run.
result:
runtime: unexpected return pc for runtime.cgocallback_gofunc called from 0x0
fatal error: unknown caller pc
runtime stack:
runtime.throw(0xb6e97b9e, 0x11)
D:/GoLang/goSource/go/src/runtime/panic.go:566 +0x80
runtime.gentraceback(0xb6e29ebc, 0x96dd43bc, 0x0, 0x96c143c0, 0x0, 0x0, 0x7fffffff, 0x868b5d04, 0x0, 0x0, ...)
D:/GoLang/goSource/go/src/runtime/traceback.go:317 +0x1620
runtime.scanstack(0x96c143c0, 0x96c2292c)
D:/GoLang/goSource/go/src/runtime/mgcmark.go:770 +0x344
runtime.scang(0x96c143c0, 0x96c2292c)
D:/GoLang/goSource/go/src/runtime/proc.go:830 +0xb0
runtime.markroot.func1()
D:/GoLang/goSource/go/src/runtime/mgcmark.go:234 +0xac
runtime.systemstack(0x96c22000)
D:/GoLang/goSource/go/src/runtime/asm_arm.s:247 +0x8c
runtime.mstart()
D:/GoLang/goSource/go/src/runtime/proc.go:1081
However, if you only once cgoCallback(s1,s2,0) is not panic.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]Android shared lib panic[/-][+]runtime: Android shared lib panic[/+]eliasnaur commentedon May 31, 2016
I'm also bitten by this in a gomobile project. Git bisect points to:
(CL 22508). I tried to blindly apply the similar CL 22651 (for arm64), but failed.
CC @ianlancetaylor
I believe this is Go1.7 material, if not Go1.7Beta.
ianlancetaylor commentedon May 31, 2016
Sorry for the difficulties. Can you try https://golang.org/cl/23586 ?
gopherbot commentedon May 31, 2016
CL https://golang.org/cl/23586 mentions this issue.