Debugging 32-bit vs. 64-bit Alignment and Deallocation Issues in JAM STAPL PLAYER
On the ASPEED evb-ast2600 platform, using a 32-bit cross compiler, the latest version of JAM STAPL PLAYER v2.6.1 can execute JAM file instructions stably. Now, we are porting the functionality of JAM STAPL PLAYER v2.6.1 to the ASPEED evb-ast2700 platform, where the cross compiler is built for a 64-bit environment. However, we have found that JAM STAPL PLAYER v2.6.1 currently supports only a 32-bit architecture, which causes the execution of JAM instructions on the ASPEED evb-ast2700 platform to trigger the error `munmap_chunk(): invalid pointer Aborted (core dumped)`.
Is there a way to make this tool compatible with a 64-bit environment? Thank you.
Figure 1: The crash location of idconde.jam
I am step-by-step tracing the source code of JAM STAPL PLAYER, focusing on the `main()` function in `jamstub.c`. From `main()`, the execution flow proceeds as follows:
1. `jam_execute()` (in `jamstub.c`)
2. `jam_execute()` (in `jamexec.c`)
3. `jam_execute_statement()`
4. `jam_process_irscan()`
5. `jam_process_irscan_capture()`
6. `jam_swap_ir()`
7. `jam_free()` (in `jamjtag.c`)
8. Finally, it reaches `free()`.
To track the program’s execution, I added log messages indicating `func start` and `func end`, along with the current status (`status is x`), in the following functions:
- `jam_process_print()`
- `jam_process_irscan()`
- `jam_swap_ir()`
- `jam_free()`
- `free()`
Through these log outputs, I found that the crash occurs at the `free()` function. At this point, I suspect the issue is related to memory deallocation, potentially caused by an invalid pointer or memory alignment problem.
Figure 2: Trace Code Sequence