Debugging memory corruption: who the hell writes "2" into my stack?

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Nutrient – The #1 PDF SDK Library, trusted by 10K+ developers
Other PDF SDKs promise a lot - then break. Laggy scrolling, poor mobile UX, tons of bugs, and lack of support cost you endless frustrations. Nutrient’s SDK handles billion-page workloads - so you don’t have to debug PDFs. Used by ~1 billion end users in more than 150 different countries.
www.nutrient.io
featured
CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
  1. llvm-project

    The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

    They passed a function that throws an exception to a C ABI function. C ABI functions cannot tolerate exceptions because C does not support stack unwinding. It might work anyway, but it is technically undefined behavior and it will only ever work when simply deallocating what is on the stack does not require any cleanup elsewhere.

    The exception caused the stack frame to disappear before the OS kernel was done with it. Presumably, the timeout would have been properly handled had the stack not been unwound by the exception. If it had not, that would be a bug in Windows.

    There is a conceptually simple solution to this issue, which is to have the C++ compiler issue a warning when a programmer does this. I filed bug reports against both GCC and LLVM asking for one:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118263

    https://github.com/llvm/llvm-project/issues/121427

    That said, this issue would not happen in Rust with a callback passed to a C function because unlike C++, Rust does not have exceptions:

    https://doc.rust-lang.org/book/ch09-00-error-handling.html

    The same issue would happen when C++ passes a callback function that can throw an exception to Rust. However, the compiler warning I proposed should protect against that, provided that programmers do not ignore it if/once it is implemented.

  2. Nutrient

    Nutrient – The #1 PDF SDK Library, trusted by 10K+ developers. Other PDF SDKs promise a lot - then break. Laggy scrolling, poor mobile UX, tons of bugs, and lack of support cost you endless frustrations. Nutrient’s SDK handles billion-page workloads - so you don’t have to debug PDFs. Used by ~1 billion end users in more than 150 different countries.

    Nutrient logo
  3. grid

    Two dimensional grid data structure (by becheran)

    If some unsafe code gets interrupted by a panic when it's in an intermediate state (before it can clean something up, or make two values consistent), then further operations on that state can result in UB. See https://github.com/becheran/grid/issues/19, https://gitlab.com/tspiteri/rug/-/issues/47, and https://gitlab.com/tspiteri/rug/-/issues/49 for a few of the less-contrived issues I've filed.

    It can also result in logic errors if objects are used after their methods panic, but such usage is generally not expected to work in the first place.

  4. rug

    If some unsafe code gets interrupted by a panic when it's in an intermediate state (before it can clean something up, or make two values consistent), then further operations on that state can result in UB. See https://github.com/becheran/grid/issues/19, https://gitlab.com/tspiteri/rug/-/issues/47, and https://gitlab.com/tspiteri/rug/-/issues/49 for a few of the less-contrived issues I've filed.

    It can also result in logic errors if objects are used after their methods panic, but such usage is generally not expected to work in the first place.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Grid v0.12.0

    1 project | /r/rust | 24 Nov 2023
  • Released grid v0.10.0

    1 project | /r/rust | 1 May 2023
  • Grid 0.8.0 released. Improved performance and fixed some minor issues

    1 project | /r/rust | 16 Aug 2022
  • Released grid v0.7.0 - Thx for all the pull-requests :-)

    1 project | /r/rust | 6 Aug 2022
  • Released grid v0.5.0 - a two dimensional data structure library for rust

    1 project | /r/rust | 23 Aug 2021

Did you know that LLVM is
the 54th most popular programming language
based on number of references?