跳过导航
Let's compare Fil-C to AddressSanitizer!
0:00 / 23:21

Let's compare Fil-C to AddressSanitizer!

Filip Jerzy Pizło

@filpizlo8770 位关注者

在 X 上查看
253 个赞下载原帖

29,864 次观看

Let's compare Fil-C to AddressSanitizer!

19 条评论

评论来自 X (Twitter) 上的原帖

  • fdesmet2021 的头像

    @fdesmet2021

    Is the local-to-heap-lifting behavior optional? I don't want a compiler to silently do things the program explicitly doesn't say (*cough* optimizer+UB *cough*). I'd rather take a Fil-C panic so the dangling pointer problem can be fixed, not masked.

    5 个赞

  • Filip Jerzy Pizło 的头像

    @filpizlo

    It’s not optional. Reason: making that be a panic would be much more expensive to implement.

    1 个赞

  • dage 的头像

    @0xda9e

    @fdesmet2021 Hm, couldn't one just always set the upper bound of the invisicap to lower in the preamble and get the panic that way?

  • Filip Jerzy Pizło 的头像

    @filpizlo

    that's more expensive than doing nothing in the epilogue. it's actually shockingly more expensive if you consider that it would mean all capability pointers to any variable ever live in the function would have to stay alive until the epilogue. That's a lot of register/stack pressure.

  • dage 的头像

    @0xda9e

    @fdesmet2021 Doesn't it depend on how often people write code like this? My assumption would be that it's not the norm (since it's usually discouraged as you mention), but yeah if it happens a lot might certainly add up.

  • Filip Jerzy Pizło 的头像

    @filpizlo

    @fdesmet2021 The compiler has no way of knowing, in the general case, whether a C local escapes or not. Some of them are proved nonescaping for sure, but enough are conservatively escaping that if we implemented your suggestion, we'd have disastrous register and stack pressure.

  • dage 的头像

    @0xda9e

    @fdesmet2021 But isn't that just because everything's an alloca in LLVM? That's a representation issue, I'm assuming that could be solved in principle🤔 one would need to be able to explicitly track where stack locals are address-taken. I guess it's a borrow-checker then.

  • Filip Jerzy Pizło 的头像

    @filpizlo

    @fdesmet2021 No, it’s because of how C works. It’s not hard to track where stack locals are address taken. The hard part is that in a large function you could easily have hundreds or even thousands of locals whose addresses are taken and passed to opaque sinks

  • End 的头像

    @ENDESGA

    Are you familiar with the fact that TinyCC can also catch such bounds errors via the `-b` option?

    4 个赞

  • Filip Jerzy Pizło 的头像

    @filpizlo

    It'll catch the obvious ones. Fil-C catches all of them.

    8 个赞

  • Gardiner Allen 的头像

    @aphexddb

    I didn’t realize Fil-C builds c++, very cool! Will have to try this out

    3 个赞

  • mintsuki 的头像

    @__mintsuki

    i should try building Limine with Fil-C

    2 个赞

  • dage 的头像

    @0xda9e

    Great explanation! Agree, the last example is perfectly valid if used correctly - also entirely obviates allocating heap memory. People pass stack locals to kthreads in the kernel all the time. Though, it can become complicated to reason about the correctness after a while 😅

    2 个赞

  • great hylord cavey phd ∿ 的头像

    @cavemanloverboy

    oh man i was with you until the end. hidden allocations are terrible. an error would be better

    1 个赞

  • Miro Knejp 的头像

    @mknejp

    @meetingcpp Not a fan of hoisting locals onto the heap. That allows writing broken non-portable code which "happens to work" on Fil-C but breaks when compiled with any other toolchain. It creates a false sense of security. Did you test that with TSan? All the other stuff, very impressive.

    1 个赞

  • Mig night 的头像

    @midtayfan

    So cool I wish I was this smart of a programmer

    1 个赞

  • Handika Wisnu 的头像

    @handikawisnu

    a combo of multi compile step: static analyzer then dynamic sanitizer caught some of these case studies (as mentioned in your video). I made my own safe_c.h header file with 600 loc preprocessor macros --> it managed to catch anything uncaught by -fanalyzer and -fsanitize.

  • Stefano Cristiano 的头像

    @pagghiu_

    Great Video! Does fil-c work on arm64 Linux? I would like to try it in an Ubuntu VM on my Mac.

  • Filip Jerzy Pizło 的头像

    @filpizlo

    No but porting it to arm64 would be easy