What can cause this SIGSEGV error?

后端 未结 2 1057
终归单人心
终归单人心 2021-01-26 08:47

I received a crash log that I cannot explain. I have searched around and it appears that the SIGSEGV has something to do with memory. But in my case there is nothin

相关标签:
2条回答
  • 2021-01-26 09:25

    SIGSEGV is a problem the occurs when your application tries to access an address of memory that doesn't exists or some address where is already reserved to another program. I have the same issue with an application right now but I have to review my code to figure it out better. One clue for this kind of problem could be something equivalent to this (found in wikipedia):

    #include <stdlib.h>  
    

    int main(void)
    {
    char p = NULL; / p is a pointer to char that initializes poiting to "nowhere"*/
    * p = 'x'; /* Tries to save the char 'x' in 'no address'*/
    return 0;
    }

    I hope this can help someone.

    0 讨论(0)
  • 2021-01-26 09:40

    The most simple and useful way to spend your time hunting for the cause of the crash is to look at your code and focus on places where UIKit has a delegate that points back into your code. For example, I found that the most common place this sort of thing would show up was in UITableView. The reason these problems are so hard to track down is that they might only happen in a low memory situation or in some uncommon UI condition that is very hard to reproduce. It is better to just do a code review and make sure that delegate that are set to point to your classes are set back to nil in your own object destructors. If you have many developers, it is often better to work on some higher level abstractions like a generic table and cell class that is used throughout the project than to have every developer coding up a UITableView and making mistakes like forgetting to nil out the delegate that are very difficult to find.

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