no invalid cross compile" />

当前位置 : 主页 > 网络编程 > 其它编程 >

IllegalinstructiononARMincJSON_Delete

来源:互联网 收集:自由互联 发布时间:2023-07-02
OnARMv7lthefollowingcodecausesanIllegalinstructionwhileitworksonX86/X64. On ARMv7l the following code causes an "Illegal instruction" while it works on X86/X64. Program (compiled using gcc directly at the device --> no invalid cross compile
OnARMv7lthefollowingcodecausesanIllegalinstructionwhileitworksonX86/X64.

On ARMv7l the following code causes an "Illegal instruction" while it works on X86/X64.

Program (compiled using gcc directly at the device --> no invalid cross compile settings):

12345678910111213CcJSON *root cJSON_ParseWithLength(data, datasize);if (cJSON_IsObject(root)) {  cJSON *op cJSON_GetObjectItem(root, "op");  char *op_name cJSON_GetStringValue(op);  if (op_name) {    printf("op: %s\n", op_name);    free(op_name);  }  printf("Crash happens between here ...\n");  cJSON_Delete(root);  printf("... and here\n");}

Input:

1data

is a valid JSON with {op: "something"},

1datasize

is strlen(data)

Output:

123op: somethingCrash happens between here ...Illegal instruction

Questions:1) Is there some (obvious) mistake with the code above?2) Is there a known issue for ARM?3) Is there any unaligned memory access (something that will cause issues on ARM but not on X86).4) Any other hint?

该提问来源于开源项目:DaveGamble/cJSON

Thank you for your support.

   

【文章原创作者:香港服务器 http://www.558idc.com/hk.html提供,感谢支持】
网友评论