News for hackers. Stuff that matters.
Re:Everything I wish I knew when learning C by hddqsb on Monday November 28, 2022 @11:16AM (#33775446)
Good one, thanks. Note that it requires Clang; GCC 12.2 doesn't have it.
Re:Everything I wish I knew when learning C by gavinray on Monday November 28, 2022 @11:36AM (#33775744)
Wow nice, I didn't know about this one. I can add some more which are less known. This is my current sanitize invocation (minus the addition of "integer" which I'll be adding, unless one of these other ones covers it):

  -fsanitize=address,leak,undefined,cfi,function
CFI has checks for unrelated casts and mismatched vtables which is very useful. It requires that you pass -flto or -flto=thin and -fvisibility=hidden.

You can read a comparison with -fsanitize=function here:

https://clang.llvm.org/docs/ControlFlowIntegrity.html#fsanit...

There's also TypeSanitizer, which isn't officially released, but is really interesting and should be able to be applied via a patch from the branch:

https://www.youtube.com/watch?v=vAXJeN7k32Y

https://reviews.llvm.org/D32199

  $ curl -L 'https://reviews.llvm.org/D32199?download=1' | patch -p1
Re:Everything I wish I knew when learning C by nwellnhof on Monday November 28, 2022 @11:41AM (#33775808)
I think "leak" is always enabled by "address". It's only useful if you want run LeakSanitizer in stand-alone mode.
Re:Everything I wish I knew when learning C by gavinray on Monday November 28, 2022 @12:05PM (#33776149)
Ah I wasn't sure if LSAN was always enabled with ASAN, good to know -- ty!