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
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:
1datais a valid JSON with {op: "something"},
1datasizeis strlen(data)
Output:
123op: somethingCrash happens between here ...Illegal instructionQuestions: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.