Android NDK Segmentation Error

前端 未结 3 1835
面向向阳花
面向向阳花 2021-01-19 10:40

In my application when I try to print my logs into file at that Time facing Segmentation Error .

I am facing Fatal Signal 11 .

My log function is into Native

相关标签:
3条回答
  • 2021-01-19 11:02

    On side note, if you are using library it is hard to find out where in your library it caused exception seeing Logs from Logcat.

    1. Get latest version of Android-NDK.
    2. Save your logcat logs some where on your drive or feed directly to ndk-stack, for example suppose you save it on C:\Error.txt
    3. If you are using Windows, open command prompt navigate to directory where you have downloaded latest Android-NDK and then run following command

    ndk-stack -sym C:\Project\libs -dump C:\Error.txt

    You can find documentation in android_ndk_path/docs/NDK-STACK.html

    0 讨论(0)
  • 2021-01-19 11:08
    char logMessage[5];
    char tempString[5];
    
    strcpy(logMessage, "1234");
    strcpy(tempString, "1234");
    
    strcat(logMessage, tempString);
    

    may (!) cause the trouble?

    0 讨论(0)
  • 2021-01-19 11:25

    The segmentation fault signal points to some type of memory problem and, taking into account that you set logMessage and tmpString to the same length and you're filling logMessage with several arguments plus the content in tmpString, as Peter states, is very possible that you're running into a buffer overflow.

    Initially, logMessage's length should be: MAX_APPNAME_LEN + MAX_DEBUG_LEN + 4 + MAX_TIMESTAMP_LEN + MAX_MODULENAME_LEN + PATHLENGTH.

    0 讨论(0)
提交回复
热议问题