在ARM架构中,incJSON_Delete的非法指令该如何处理?

2026-04-03 02:001阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计222个文字,预计阅读时间需要1分钟。

在ARM架构中,incJSON_Delete的非法指令该如何处理?

在ARMv7l上运行时,以下代码会导致非法指令错误,而在X86/X64上则没有问题。程序(使用gcc在设备上直接编译)--》没有无效的交叉编译。

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:

在ARM架构中,incJSON_Delete的非法指令该如何处理?

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.

   

本文共计222个文字,预计阅读时间需要1分钟。

在ARM架构中,incJSON_Delete的非法指令该如何处理?

在ARMv7l上运行时,以下代码会导致非法指令错误,而在X86/X64上则没有问题。程序(使用gcc在设备上直接编译)--》没有无效的交叉编译。

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:

在ARM架构中,incJSON_Delete的非法指令该如何处理?

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.