Skip to content
HomeVideosBooksBlogs
AllTop postsTopics
Podcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    T

    TrustInSoft Blog

    trust-in-soft.com · Company blog · on HN since 2014

    TrustInSoft, a company that sells static analysis tools for C and C++, writes about undefined behavior and compiler quirks in C.

    Visit blogHN submissions
    Languages & CompilersSecurityProgramming
    What HN says

    HN commenters point to the company as a source of sound analysis tools that guarantee no undefined behavior in C, and cite its GCC alignment post.

    Stats for nerds
    30HN people shared it
    19linked in comments
    194story points
    Sep 2025last shared
    2014people per year2025

    Top posts on HN

    1. 1
      Ways C compilers break for objects larger than PTRDIFF_MAX bytes
      3 people · 75 points · first shared 2016 · 18 comments on HN
    2. 2
      GCC always assumes aligned pointer accesses
      3 people · 67 points · first shared 2020 · 91 comments on HN
    3. 3
      Memcmp requires pointers to fully valid buffers
      2 people · 21 points · first shared 2016 · 1 comments on HN
    4. 4
      Handling security bugs is not the open-source community’s strong point
      1 person · 5 points · first shared 2015 · Discussion on HN
    5. 5
      A dangling pointer is indeterminate
      3 people · 4 points · first shared 2015 · Discussion on HN
    6. 6
      Tis-interpreter detects subtle bugs in C programs
      4 people · 3 points · first shared 2015 · 2 comments on HN
    7. 7
      Detecting Strict Aliasing Violations in the Wild [pdf]
      3 people · 3 points · first shared 2017 · Discussion on HN
    8. 8
      Out-of-bounds pointers: a common pattern and how to avoid it
      3 people · 3 points · first shared 2016 · Discussion on HN
    9. 9
      A C SSL implementation without buffer overflows
      2 people · 3 points · first shared 2014 · Discussion on HN
    10. 10
      Printing a null pointer with %s is undefined behavior
      1 person · 3 points · first shared 2019 · Discussion on HN

    What HN people wrote when they linked it

    • pascal_cuoqApr 2020

      I still want to write at least one sequel to that post, on the theme “Alright, can we make a Friendly C Compiler by disabling the annoying optimizations, then?”.

      Obviously the people who want a Friendly C Compiler do not want to disable all optimizations. This would be easy to do, but these users do not want the stupid 1+2+16 expressions in their C programs, generated through macro-expansion, to be compiled to two additions with each intermediate result making a round-trip through memory.

      So the question is: can we get a Friendly C Compiler by enabling only the Friendly optimizations in an unfriendly compiler?

      And for the answer to that, I had to write an entire other blog post as preparation, to show that there are some assumptions an optimizing compiler can do:

      - that may be used in one or several optimizations, but the compiler authors did not really keep track of where they were used,

      - that cannot be disabled and that the compiler maintainers will not consider having an option to disable,

      - and that are definitely unfriendly.

      Here is the URL of the blog post that I had to write in preparation for the upcoming blog post about getting ourselves a Friendly C Compiler: https://trust-in-soft.com/blog/2020/04/06/gcc-always-assumes-aligned-pointers/ . I recommend you take a look, I think it is interesting in itself.

      You will have guessed that I'm not optimistic about the approach. We can try to maintain a list of friendly optimizations for ourselves, though, even if…

    • JoachimSchipperJan 2016

      So, any experience reports?

      I can recommend https://www.imperialviolet.org/2014/09/07/provers.html.

      Personally, I tried to prove that a fairly simple program I had written a few years prior was free of undefined behavior. Frama-C was tantalizingly capable - it was easy to tell Frama-C what I wanted to prove, and it managed to propagate possible values and control flow through the program pretty accurately, even with minimal assistance. Although I disliked the absence of a usable text-mode integration (vim?), the GUI presented the results clearly. The Frama-C manuals were extensive, mostly up-to-date, and managed to explain even complicated concepts in a pretty clear way. (Fair warning: although I have zero background in formal methods, I have quite a lot of mathematical training and like language lawyering.)

      Unfortunately, Frama-C did not grok malloc() at the time. My program consisted of I/O into malloc()'ed buffers plus some processing. Teaching Frama-C about malloc() was clearly beyond my skill. Worse, I really wanted to prove that my program output was some suitably processed form of its input data, and I didn't look forward to trying to model read()/write() - so I stopped the experiment, and planned to revisit Frama-C in a couple years.

      Actual experts can apparently get much better results: Frama-C was used to prove that chunks of PolarSSL were free of certain undefined behavior (http://blog.regehr.org/archives/1261, or the actual report at…

    • mananaysiempreDec 2022

      No, ssize_t is not the signed version. As best as I can tell, the only things POSIX says about ssize_t is that[1] it is an integer type that can hold integer values in [-1, SSIZE_MAX], where[2] SSIZE_MAX ≥ _POSIX_SSIZE_MAX = 32767, not that it should have any particular relation to size_t. In the standard, it is used for byte counts in I/O, like the return value of read() (traditionally int), for the return value of strfmon() and strfmon_l() (OK I guess, though the C standard stuck with int for *printf()), and for the argument to swab() (wat).

      Note that neither is ptrdiff_t guaranteed to be that signed version, or to hold any possible value in the domain of size_t or (strictly speaking) any possible object size. Both GCC and Clang assume the latter, though, and can miscompile[3] code that relies on (e.g.) malloc() succeeding for sizes > 2^31 on a 32-bit system.

      [1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html

      [2] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html

      [3] https://trust-in-soft.com/blog/2016/05/20/objects-larger-than-ptrdiff_max-bytes/

    • WalterBrightSep 2025

      No, I haven't kept track of the reports I've seen. They all had array bounds as the #1 error encountered in shipped code.

      Edit: I just googled "causes of memory safety bugs in C++". Number 1 answer: "Buffer Overflows/Out-of-Bounds Access"

      "Undefined behavior in C/C++ code leads to security flaws like buffer overflows" https://www.trust-in-soft.com/resources/blogs/memory-safety-issues-still-plague-new-c-cpp-code

      "Some common types of memory safety bugs include: Buffer overflows" https://www.code-intelligence.com/blog/memory_safety_corruption

      "Memory Safety Vulnerabilities 3.1. Buffer overflow vulnerabilities We’ll start our discussion of vulnerabilities with one of the most common types of errors — buffer overflow (also called buffer overrun) vulnerabilities. Buffer overflow vulnerabilities are a particular risk in C, and since C is an especially widely used systems programming language, you might not be surprised to hear that buffer overflows are one of the most pervasive kind of implementation flaws around." https://textbook.cs161.org/memory-safety/vulnerabilities.html

    • nickpsecuritySep 2018

      Two others worth checking out that focus on soundness with low to no false positives are RV-Match and TrustinSoft Analyzer:

      https://runtimeverification.com/match/

      https://trust-in-soft.com/products/

      The RTV people are the one's behind K framework and an executable semantics for C with a GCC-like interface:

      http://www.kframework.org/index.php/Main_Page

      https://github.com/kframework/c-semantics

      That RV-Match builds on an open framework, does well on benchmarks (yeah skepticism here), and has little to no noise (most important) is what I like most about it. I say most important since digging through false positives makes developers not want to use a tool. I haven't tried either product myself, though.

      Here's a list of open tools that did well in small-scale experiments with and without false positives:

      https://klee.github.io

      http://www.cprover.org/cbmc/

      https://cseweb.ucsd.edu/~rjhala/blast.html

      http://www.splint.org

      http://spinroot.com/uno/

      http://cppcheck.sourceforge.net/#features

      https://en.wikipedia.org/wiki/Sparse

      https://cpachecker.sosy-lab.org

    • MaxBarracloughDec 2020

      Even there it depends. 'Programming practices' is vague. Even C can be tamed, at great expense, using formal methods techniques. [0][1][2][3] Adoption of such methods can give a solid assurance of the lack of UB, like use of a safe language. Weaker measures, like adopting MISRA C, don't provide such strong assurances (although they can eliminate certain categories of errors), and as you indicate, their real value is a bit more subjective. Mandating a bad programming style could actively make things worse.

      [0] https://trust-in-soft.com/

      [1] https://www.eschertech.com/products/perfect_developer.php

      [2] https://github.com/microsoft/Armada

      [3] https://www.microsoft.com/en-us/research/project/vcc-a-verifier-for-concurrent-c/

    Related

    John Regehrblog.regehr.org401 people

    Teaching C

    John Regehr
    Personal · last shared 2026
    LLVM Blogblog.llvm.org226 people

    Clang Is Now Used to Build Chrome for Windows

    LLVM Blog
    Company · last shared 2026
    Herb Sutterherbsutter.com204 people

    Bjarne Stroustrup on Dennis Ritchie: They said it couldn't be done, & he did it

    Herb Sutter
    Personal · last shared 2026
    AdaCore Blogblog.adacore.com106 people

    Nvidia Security Team: “What if we just stopped using C?” (2022)

    AdaCore Blog
    Company · last shared 2025
    Joanna Rutkowskatheinvisiblethings.blogspot.com91 people

    The Linux Security Circus: On GUI isolation

    Joanna Rutkowska
    Personal · last shared 2026
    Andrzej's C++ blogakrzemi1.wordpress.com35 people

    A bug in GCC that may cause memory leaks in valid C++ programs

    Andrzej's C++ blog
    Personal · last shared 2025
    PVS-Studio Blogviva64.com135 people

    Criticizing the Rust Language, and Why C/C++ Will Never Die

    PVS-Studio Blog
    Company · last shared 2021
    Embedded Gurusembeddedgurus.com45 people

    Are we shooting ourselves in the foot with stack overflows?

    Embedded Gurus
    Publication · last shared 2024