August 30th, 2024

Scpptool – a tool to enforce a memory and data race safe subset of C++

scpptool is a command line tool that enforces memory and data race safety in C++ by analyzing code for unsafe areas, compatible with Clang and providing extensive documentation and resources.

Read original articleLink Icon
Scpptool – a tool to enforce a memory and data race safe subset of C++

scpptool is a command line tool designed to enforce a memory and data race safe subset of C++ in conjunction with the SaferCPlusPlus library. It analyzes C++ files to identify unsafe code areas, ensuring compliance with memory and data race safety standards. The tool is compatible with the Clang compiler and requires Clang+LLVM libraries. It features checks for memory safety, prohibiting null values for raw pointers and treating standard library containers as unsafe. Its flow-insensitive analysis allows for scalable safety checks that are not dependent on program flow. Users can also suppress specific checks locally using directives. The tool can be built on Ubuntu Linux, with detailed instructions provided in the repository. Usage is straightforward, allowing users to specify source files and compiler options easily. The repository includes examples of safe code and comprehensive documentation on using the tool, including annotations for lifetimes and safe pointer management. Additional resources, such as quick intro videos and transcripts, are available for further insights into the tool's functionality.

- scpptool enforces a safe subset of C++ for memory and data race safety.

- It is compatible with the Clang compiler and requires Clang+LLVM libraries.

- The tool allows local suppression of specific safety checks in the code.

- Detailed documentation and examples are provided in the repository.

- Additional resources include videos and transcripts for better understanding.

Link Icon 4 comments
By @comex - 8 months
Some pretty… interesting… naming conventions. One of the types is called:

    mse::rsv::TXSLTACSSSXSTERandomAccessIterator
What to make of this? The readme provides this guidance:

> The "CSSSXSTE" part of the typenames stands for "Contiguous Sequence, Static Structure, XSLTA, Type-Erased".

But it nowhere defines XSLTA. With some help from ChatGPT, I can guess that "XS" stands for "execution scope" (since the readme talks a lot about execution scopes), and "LTA" probably stands for "lifetime annotated" (since one part says that "rsv::TXSLTAOwnerPointer<> is a 'lifetime annotated' version of TXScopeOwnerPointer<>").

But what about the namespaces, "mse" and "rsv"? I can find nothing to explain what those might stand for.

Anyway.

I really like the idea of this project. There are contexts where I cannot use Rust and would love to have a way equivalent safety guarantees in C++. Even at the cost of rewriting the code. And even at the cost of ugly code, because there will be some necessary ugliness when retrofitting lifetimes into C++'s existing syntax and semantics.

But "TXSLTACSSSXSTERandomAccessIterator" is unnecessary ugliness. There are better ways to get ideas across than acronym soup.

There are some other practical issues with the project, such as inconsistent licensing annotations, and the fact that it seems to depend on specific Clang versions (and thus will probably bitrot if it stops being maintained).

Still, it seems promising and I may use it someday.

By @rurban - 8 months
I just tried it out. Still needs debugging CODE, lots of IF_DEBUG code, crashes with -DNDEBUG.
By @cozzyd - 8 months
I don't know why an uncapitalized makefile irks me so (even though apparently GNU make will read makefile before Makefile).