Crash when running Acados C example on a limited OS

Dear acados developers,

I am currently working on porting Acados (with the hpipm solver) to the RK2206 (Cortex-M4) platform running OpenHarmonyOS 3.0-LTS LiteOS-M. The compilation and linking processes have been successful, but the system crashes when running the ocp_qp.c example. Below are the detailed information:

  • Target Platform: RK2206 (Cortex-M4), OpenHarmonyOS 3.0-LTS LiteOS-M

  • Problem: when running ocp_qp.c. The fault address is 0xabababab, indicating an access to uninitialized memory

  • Limitation: OpenHarmonyOS 3.0-LTS LiteOS-M does not support calloc and only supports malloc.

Memory Allocation Logs:

  • Size of dims structure: zu bytes → Suspected format string error (%zu not supported).

  • Config memory size: 0.21 KB → The allocated memory size is small, but the crash may be caused by uninitialized memory.

My question:

  • What is the cause for the error? Our team suspect the memory initialization issue.

  • Is it possible to replace calloc with malloc plus manual initialization in Acados? If so, how to do this in a systematic way? (probably modifying the utils/mem.c ?)

  • Should the same modification apply to HPIPM?

Thank you so much in advance.

Best regards,

Yutao

Hi Yutao,

calloc is not really used in acados, only above the C interface, in the templated code. It should be rather easy to get rid/ replace it by something else.
Modifying the mem.c file seems like a good idea.
I don’t think the config memory size is too small, but it would make sense to compare such things with a different system where you can run your code.
I don’t think you need to change anything in HPIPM.

I did never test acados on such a setup.
However, a PR which enables this is highly appreciated.

Good luck and best regards,
Jonathan