Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rclc_support_init is corrupting FreeRTOS Heap #657

Open
DrMarkusKrug opened this issue Aug 1, 2023 · 3 comments
Open

rclc_support_init is corrupting FreeRTOS Heap #657

DrMarkusKrug opened this issue Aug 1, 2023 · 3 comments

Comments

@DrMarkusKrug
Copy link

Issue template

  • Hardware description: STM32L4
  • RTOS: FreeRTOS
  • Installation type: standard
  • Version or commit hash: humble

Steps to reproduce the issue

I created a FreeRTOS heap with 16kByte and a 'Standard Task' with 12000 Bytes. Additionally I created 2 binary Semaphores.

Expected behavior

Semaphores stay as they are, completely independent of the micro ROS function cals

Actual behavior

in the function call rclc_support_init it seems that the FreeRTOS Heap gets corrupted and the semaphores get affected. Maybe other FreeRTOS elements as well
beforeCorruption

Additional information

@DrMarkusKrug
Copy link
Author

afterCorruption

@YuriiHordiienko1987
Copy link

YuriiHordiienko1987 commented Jul 20, 2024

Hello, Dear experts!
As @DrMarkusKrug described the problem, I've also stumbled with the similar one.
I use heap_4 in FreeRTOS with static heap (ucHeap) definition.

I defined custom allocators (identically to @DrMarkusKrug's example) for heap_4 according to many examples out of box, then wanted to initialize rcl as well, but it seems the program crashed at the last function call rcl_init_options_init, i.e. not at the rclc_support_init:

rcl_init_options_t init_options = rcl_get_zero_initialized_init_options();
RCCHECK(rcl_init_options_init(&init_options, allocator));

I see the issue was opened, but it really makes sense to investigate the problem further. I will do an effort from my side too.
CC: @pablogs9
Thanks!

UPD: detected issue comes from rmw_init_options_init function.

@DrMarkusKrug
Copy link
Author

Hi,

I did not investigate the matter further after I got it working for me. As I recall, I changed the recommended memory allocation scheme significantly and used the FreeRTOS malloc wrappers.
If needed, I can look it up again and provide further guidance.
As far as I understood Pablo last year, the problem may not be in microros at all, but in ROS2 (which is partly used by microros). Probably because the architects of ROS2 were not aware of the actual memory limitations of a real-time operating system on a relatively small µC - or it was never a development goal to support small µC. So I don't know if the problem can be changed that easily.
I've written about this a few times before. In my opinion, the whole ROS1/2 architecture has been developed completely ignoring the reality of µC. Yes, ROS1/2 is an interesting concept with a large number of tools and possibilities. But it only works acceptably (if at all) on embedded systems in the class of an nvidia Jetson or raspberry Pi because it requires a lot of memory and CPU resources. In my opinion, however, this class of processors are no longer µCs, but already very powerful processor systems for which complex operating systems are available.

Best Regards
Markus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants