How to use AddressSanitizer in S32 Design studio

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use AddressSanitizer in S32 Design studio

2,051 Views
gberthiaume
Contributor III

As s32 design studio use gcc, I've tried to use the -fsanitize=address compiler flag in the project settings without success: The program just won't compile. 


Is it possible to use AddressSanitizer on S32K codebases? I think this would bring a lot of value to the ecosystem. 

Regards,
~gb

3 Replies

1,859 Views
ErichStyger
Senior Contributor V

Hi Gabriel,

the reason why you cannot compile is because if you turn on that option, you need a corresponding runtime environment which is not included in the S32DS environment. The compiler option alone only instruments your code, but you still need the runtime code. You find the runtime code documented e.g. in AddressSanitizerAlgorithm · google/sanitizers Wiki · GitHub. Additionally, that feature has originated from the LLVM/Linux/Web Browser world, and I have not seen an adoption for the more constrained embedded world of things. But I agree: it would be very useful. Having said that: I have been experimenting with AddressSanitizer for a while already building up some code base and examples, especially around FreeRTOS. But not for S32DS, my use case is MCUXpresso, but I don't see a reason why this would not be transferable to the DS world. I plan to document it maybe with a tutorial on my blog at MCU on Eclipse | Everything on Eclipse, Microcontrollers and Software  of I find time, but currently a bit under a crunch because of the university exam season.

I hope this helps,

Erich

1,859 Views
gberthiaume
Contributor III

Thanks for your answer Erich.
As a frequent reader of your blog, it will be my pleasure to read about this subject.

 
Best Regards,

Gabriel 

1,622 Views
ErichStyger
Senior Contributor V

Hi @gberthiaume ,

finally I have found the time to write about it:

https://mcuoneclipse.com/2021/05/31/finding-memory-bugs-with-google-address-sanitizer-asan-on-microc...

 

I hope this helps,

Erich