Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

c - Facing Illegal Instruction -4 with MacOS Catalina 10.15 code run

I have a working code on MacOS 10.14 but since I have updated MacOS to catalina 10.15, code compilation is fine but on running it is giving Illegal Instruction - 4. Not running for the input. Has anyone faced any similar issue or any suggestions over this ?

#if __has_builtin(__builtin___strcpy_chk) || defined(__GNUC__)
#undef strcpy
// char *strcpy(char *dst, const char *src) 
#define strcpy(dest, ...) 
        __builtin___strcpy_chk (dest, __VA_ARGS__, __darwin_obsz (dest))
#endif

unsigned char xName[512],yName[512];


char* my_strcpy(char *d, const char* s){
    char *r = d;
    int local_len=0;
    while (*s){
        *(d++) = *(s++);
        local_len++;
    }
    *d = '';
    return r;
}
  1. strcpy(xName,yName) crashing
  2. my_strcpy(xName,yName) working fine.
question from:https://stackoverflow.com/questions/65873766/facing-illegal-instruction-4-with-macos-catalina-10-15-code-run

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...