Compiling Chrome with Sanitizers

22 views
Skip to first unread message

Yizhuo Zhai

unread,
Jan 31, 2023, 12:37:52 PMJan 31
to Chromium-dev
Hi All:
I'm trying to compile Chrome with C++/C sanitizers, by adding -fsanitize options after flags in toolchain.ninja. But the protoc is broken after doing so, if I understand correctly, protoc is used to generate some files, therefore, I do not need to instrument the instructions in it. 

I wonder which folder will finally compiled into the chrome binary, and I think it's ok to add the flag to those sub-modules in chrome. Could anyone give me the hint on the code that would finally compiled into the Chrome? And the correct location to add the flags? I appreciate any help you can give.

Peter Boström

unread,
Jan 31, 2023, 12:46:32 PMJan 31
to yzha...@ucr.edu, Chromium-dev
Depending on what sanitizer you're interested in running we have gn arguments for is_asan, is_ubsan, is_msan and is_tsan. Maybe I've forgotten some, like is_lsan. 


For asan there's documentation here, I dunno where the rest are: https://chromium.googlesource.com/chromium/src/+/main/docs/asan.md

Good luck!
Peter

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/76f78390-c0e6-4aa6-b3ae-1dad075b7626n%40chromium.org.

Peter Boström

unread,
Feb 1, 2023, 12:23:14 PMFeb 1
to Yizhuo Zhai, Chromium-dev
Maybe https://chromium.googlesource.com/chromium/src/+/main/docs/clang.md#using-a-custom-clang-binary will help as well as using the sanitizer.gni as a base for your work.

On Tue, Jan 31, 2023 at 5:17 PM Yizhuo Zhai <yzha...@ucr.edu> wrote:
Hi Peter:
Thanks for your suggestions, K. Moon also replied to me with a similar answer, sorry for the duplicated question. 
I actually need to use a research clang sanitizer which does not exist in the current building system.
I would refer to the document you show and I appreciate your help very much.
--
Kind Regards,

Yizhuo Zhai

Computer Science, Graduate Student
University of California, Riverside 

Yizhuo Zhai

unread,
Feb 1, 2023, 3:09:55 PMFeb 1
to Peter Boström, Chromium-dev
Hi Peter:
Thanks for the doc, configuring clang_base_path and adding the sanitizer options (-fsanitize=) to the toolchain.ninja are exactly the thing I did, there are a few troubles regarding flatc, cddl, protobuf, and some generators (returns error status -11, etc). 

I have written a bin/sh wrapper not to instrument c/c++ code under those submodules as I think the final chrome would not contain any code from those third party tools. But please let me know if you think this is incorrect.

 I'm also studying how to deploy the sanitizer from asan, if the previous approach fails, I would deploy the customized sanitizer as what asan did. It seems it needs to modify some configuration files(.gn or .gni as you pointed) to set up the sanitizer option and add some flags. 
Reply all
Reply to author
Forward
0 new messages