|
本帖最后由 tigerA15 于 2016-3-1 17:24 编辑
在api里面有一個test function:
procedure jni_test(Env: pJNIEnv; this: JObject;pvSrc:jbyteArray;pvOut:jbyteArray;pvSize:jint); cdecl;
var i:integer;
var lvSrc,lvRet:TByteDynArray;
var lvSize:jsize;
var lvFlag:String;
begin
try
lvFlag:=inttostr(integer(pvSrc));
except
on e:exception do begin
logi('ee:'+e.message);
end;
end;
exit;
//logi(lvFlag+ ' CV bytes');
//logi(lvFlag+ 'enter, do nonthing');
JNI_Enter();
//logi(lvFlag+ ' try to cv .');
try
//lvSrc:= JNI_JByteArrayToBytes(Env, pvSrc);
//logi(lvFlag+ ' cv done .');
//setlength(lvSrc,0);
sleep(10);
finally
JNI_Leave();
// logi('leave.');
end;
{lvFlag:=inttostr(integer(pvSrc));
logi(lvFlag+ ' CV bytes');
lvSrc:= JNI_JByteArrayToBytes(Env, pvSrc);
logi(lvFlag+ ' CV bytes 1');
lvRet:= JNI_JByteArrayToBytes(Env, pvOut);
logi(lvFlag+ ' CV bytes 2');
for i:=0 to pvSize-1 do begin
lvRet:=lvSrc+1;
end;
lvSize := Env^^.GetArrayLength(env, pvOut);
Env^^.SetByteArrayRegion(env,pvOut,0,lvSize,@lvRet[0]);
}
end;
其實什么也沒做,然后在android層面開5個線程并發調用之:
public static native void test(byte[] pvSrc,byte[] pvOut,int pvSize);
final byte[] lvSrc=new byte[]{1,2,3,4};
for (int i=0;i<5 ;i++){
new Thread(new Runnable() {
@Override
public void run() {
byte[] lvRet=new byte[lvSrc.length];
for (int i=0;i<500;i++){
ImageCompare.test(lvSrc, lvRet, lvSrc.length);
Log.i("",""+lvRet[3]);
}
}
}).start();
}
然而就會直接退出毫無提示及exception log,或logcat里面提示libc錯誤:
Fatal signal 11 (SIGSEGV) at 0x00010008 (code=1), thread 10658 (Thread-7144)
請問有什么解決方法?
|
|