I got following error while exec shell in android jni

I need to change the file name(/system/etc/asound.conf) in android native jni. I can do this in serial port by run shell cmd:

mount -o remount rw /system
busybox mv /system/etc/asound.conf /system/etc/asoundback.conf
mount -o remount r /system

First, I run above shell script in in java by invoking Runtime.getRuntiem(String). Ihis will result in all android system services reload. So I didn't do like this.

I run above shell script in jni by invoking system() like this:

android_media_AudioSystem_changeFileName(JNIEnv *env, jobject thiz, jstring from, jstring to) 
{
    const jchar* c_from = env->GetStringCritical(from, 0); 
    String8 c_from8;
    if (from) {
        c_from8 = String8(c_from, env->GetStringLength(from));
        env->ReleaseStringCritical(from, c_from);
    }   

    const jchar* c_to = env->GetStringCritical(to, 0); 
    String8 c_to8;
    if (to) {
        c_to8 = String8(c_to, env->GetStringLength(to));
        env->ReleaseStringCritical(to, c_to);
    }   

    LOGV("*********** android_media_AudioSystem_changeFileName from: %s  ,to: %s" ,c_from8 ,c_to8);
    char buff[4096];
    sprintf(buff ,"mount -o remount rw /system;busybox mv %s %s;mount -o remount r /system" ,c_from8 ,c_to8);
    if(system(buff) == -1) return -1; 
    return 0;
}

It does not work. The log is:

[  197.520000] mclkdiv = 2, bitclkdiv = 12
D/ALSAModule( 1160): open called for devices 00000002 in mode 0...
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker_normal
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback
I/ALSAModule( 1160): Initialized ALSA PLAYBACK device defaul
D/SoundSettings( 2041): ******* audio channel: codec
D/SoundSettings( 2041): ******* before asound-----> asoundback
I/AudioSystem( 2041): *********** android_media_AudioSystem_changeFileName
F/libc    ( 2041): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
I/DEBUG   ( 1155): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 1155): Build fingerprint: 'android:4.0.3/IML74K/eng.android.20120717.210618:eng/test-keys'
I/DEBUG   ( 1155): pid: 2041, tid: 2041  >>> com.android.settings <<< 
I/DEBUG   ( 1155): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaadI/DEBUG   ( 1155):  r0 deadbaad  r1 00000001  r2 40000000  r3 00000000
I/DEBUG   ( 1155):  r4 00000000  r5 00000027  r6 62100021  r7 411afa18
I/DEBUG   ( 1155):  r8 be9b8644  r9 be9b864c  10 4786445b  fp be9b8684
I/DEBUG   ( 1155):  ip ffffffff  sp be9b8618  lr 40068f01  pc 40065660  cpsr 60000030
I/DEBUG   ( 1155):          #00  pc 00017660  /system/lib/libc.so
I/DEBUG   ( 1155):          #01  pc 0006f9de  /system/lib/libandroid_runtime.so
I/DEBUG   ( 1155):          #02  pc 0001ebf0  /system/lib/libdvm.so (dvmPlatformInvoke)
I/DEBUG   ( 1155):          #03  pc 00058c38  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread)
I/DEBUG   ( 1155):
I/DEBUG   ( 1155): code around pc: 
I/DEBUG   ( 1155): 40065640 4623b15c 2c006824 e026d1fb b12368db  \.#F$h.,..&..h#.
I/DEBUG   ( 1155): 40065650 21014a17 6011447a 48124798 24002527  .J.!zD.`.G.H'%.$
I/DEBUG   ( 1155): 40065660 f7f47005 2106ef70 effef7f5 460aa901  .p..p..!.......F
I/DEBUG   ( 1155): 40065670 f04f2006 94015380 94029303 ebc8f7f5  . O..S..........
I/DEBUG   ( 1155): 40065680 4622a905 f7f52002 f7f4ebd2 2106ef5c  .."F. ......\..!
I/DEBUG   ( 1155):
I/DEBUG   ( 1155): code around lr: 
I/DEBUG   ( 1155): 40068ee0 41f0e92d 46804c0c 447c2600 68a56824  -..A.L.F.&|D$h.h
I/DEBUG   ( 1155): 40068ef0 e0076867 300cf9b5 dd022b00 47c04628  gh.....0.+..(F.G
I/DEBUG   ( 1155): 40068f00 35544306 37fff117 6824d5f4 d1ee2c00  .CT5...7..$h.,..
I/DEBUG   ( 1155): 40068f10 e8bd4630 bf0081f0 000285fa 41f0e92d  0F..........-..A
I/DEBUG   ( 1155): 40068f20 fb01b086 9004f602 461f4815 4615460c  .........H.F.F.F
I/DEBUG   ( 1155):
I/DEBUG   ( 1155): memory map around addr deadbaad:

Someelse can help me ? Thanks a lot!!!

Answers


I am not an expert in the tracelogs, but from what I can make of it you have :

1. Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1) 

this means memory corruption, deadbaad means corrupted memory..

2. I/DEBUG   ( 1155): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaadI/DEBUG   ( 1155):  r0 deadbaad  r1 00000001  r2 40000000  r3 00000000

this means the registries are null or 0..

I cannot help further, since I have no idea what you'r doing, but I guess that you are making a wrong read somewhere..


Need Your Help

rails - how to override default views

ruby-on-rails views

by default, when i ask rails controller to do messages/index, he does

Tutorial for ClojureBox

emacs netbeans clojure

I'm trying to learn clojure. ClojureBox appears to be similar to LispBox - http: //gigamonkeys.com/lispbox/ which I've used previously.