Functional safety standards such as ISO 26262 emphasize the importance of systematic development, verification, and validation activities throughout the software lifecycle. However, compliance with a standard is not achieved simply by selecting technologies that are themselves standardized. Confidence must ultimately be established in the actual implementations that are integrated into a safety-related system.

A defect in the LLVM C++ standard library implementation (libc++), reported by Validas, provides a useful example. During our C++ Library Qualification (LQ) of the C++ Standard Library for safety-related use, our engineers identified a case in which the implementation of std::async did not behave as required by the C++ Standard when thread creation failed. Instead of reporting an error through the required exception mechanism, the application hung, freezing and waiting indefinitely. The issue was reported to the LLVM project and fixed, with the fix merged into the upstream LLVM project in June 2025. Check the issue on github.

While this specific defect affected a particular implementation and execution scenario, its significance extends beyond a single bug report. It highlights broader challenges related to software qualification, library assessment, requirements-based verification, and the role of toolchain components in safety-critical systems. The problem occurs when a program requests a new background task (a thread), but the system has no resources left to create one.

Understanding the Role of Standard Libraries in Safety-Critical Software

Understanding the Role of Standard Libraries in Safety-Critical Software

Modern embedded software rarely consists solely of application-specific code. Most projects depend heavily on external software components, including programming language runtimes, standard libraries, operating system services, communication stacks, mathematical libraries, and middleware frameworks.

In C++, the standard library provides a substantial portion of the functionality used by developers every day. Containers, threading facilities, memory management mechanisms, algorithms, and synchronization primitives are typically implemented by the library rather than by application developers.

As a result, the behavior of these components directly affects the behavior of the final system.

Standards Define Expected Behavior

Standards Define Expected Behavior

A common misconception is that standardized functionality is inherently trustworthy simply because it is specified in an international standard. In reality, standards define requirements, not implementations. Think of a standard as a recipe: it describes the expected result, but it does not guarantee that every kitchen will follow it correctly.

For C++, the language and library requirements are specified in ISO/IEC 14882. Multiple implementations exist, including GNU libstdc++, LLVM libc++, and Microsoft STL. Each implementation is responsible for translating the requirements of the specification into executable code. Consequently, conformity with the standard depends on the implementation behaving correctly in practice, not merely on the existence of a specification.

The std::async Case Study

The std::async Case Study

The std::async facility allows a function to be executed asynchronously, typically on a new thread (a separate path of execution), and returns a std::future object through which the result can be retrieved later.

The C++ Standard specifies how such operations must behave under both normal and exceptional conditions. One of these requirements concerns thread creation failures.

According to the standard, when std::async is invoked with the std::launch::async launch policy and the implementation is unable to start a new thread, a std::system_error exception must be thrown. The specified error condition is resource_unavailable_try_again. In plain terms, if the system cannot start a new task, the program must report an error that it can handle.

This behavior is important because it provides a predictable mechanism for error handling. Applications can catch the exception, report the failure, initiate recovery actions, or transition to a safe state.

What Was Observed

What Was Observed

During qualification activities for the C++ Standard Library, our engineers intentionally exhausted the thread resources available to the application by setting platform-specific resource limits and repeatedly requesting new threads until the limit was reached.

The expected behavior was that the library would comply with the standard and report the error by throwing a std::system_error exception.

Testing revealed different behavior across implementations:

  • GNU's libstdc++ produced the expected exception on Linux.

  • LLVM's libc++ caused the application to hang instead of reporting the error condition.

The issue was reproducible when thread creation became impossible because operating-system limits had been reached. The same situation can occur during real operation when a system runs low on resources, not only under test conditions.

Why the Difference Matters

Why the Difference Matters

From a safety perspective, a reported failure and an application hang are fundamentally different outcomes.

When an exception is generated, the application remains aware of the failure, diagnostics can be triggered, safety mechanisms can be activated, and recovery procedures can be executed.

When an application hangs, monitoring functions may be bypassed, recovery logic may never execute, external observers may receive no clear indication of the failure, and timing assumptions may be violated.

The issue therefore went beyond standards conformance. It affected the software’s ability to respond predictably under fault conditions

Why Safety Engineers Care About Corner Cases

Why Safety Engineers Care About Corner Cases

Some of the most important software risks only become visible under unusual conditions. For safety engineers, these corner cases are therefore an essential part of assessing system behavior.

Rare Conditions Often Reveal Critical Weaknesses

Rare Conditions Often Reveal Critical Weaknesses

Many software defects become visible only under circumstances that are unusual during normal operation. Examples include memory exhaustion, processor overload, communication timeouts, file system failures, power disturbances, and thread creation failures.

These situations may occur infrequently in production systems, but safety standards place considerable emphasis on their analysis because they often determine how a system behaves when something goes wrong.

Error Handling Is a Safety Function

Error Handling Is a Safety Function

Functional safety engineering frequently focuses on nominal functionality. However, many hazards arise during abnormal operation. For this reason, standards such as ISO 26262 require systematic consideration of fault conditions and failure responses.

In software, error handling mechanisms often constitute safety mechanisms themselves.

Implications for Software Qualification

Implications for Software Qualification

One important lesson from this case is that long-established and widely deployed software components may still contain defects relevant to safety applications. The LLVM community responded by fixing the issue, showing how open-source collaboration can improve software quality for everyone.

This reinforces a key principle of safety engineering: popularity is not evidence of suitability for a particular safety-related use case.

The defect was identified because qualification activities compared the actual behavior of the implementation with the documented requirements. This is a fundamental verification approach within ISO 26262 and related safety standards. In simple terms: we compared what the standard promises with what the software actually does and found a difference.

Qualification must cover all relevant components of the executable system. While safety assessments often focus on application software, the final executable also depends on compilers, runtime and standard libraries, linkers, startup code, operating systems, and communication stacks.

The Challenge of Library Qualification

The Challenge of Library Qualification

A recurring challenge in software qualification is determining what actually needs to be assessed. Modern standard libraries contain extensive functionality, much of which may never be used by a particular application. Many safety projects therefore focus on the subset of library functionality that contributes to the deployed system. However, even rarely used features can be relevant, so the scope of the assessment must be justified. This typically involves identifying the functionality used, tracing it to requirements, verifying the relevant behavior, and analyzing residual risks.

Toolchains and Safety Arguments

Toolchains and Safety Arguments

Safety-relevant issues do not necessarily originate in the application’s own source code. Software execution depends on multiple layers, including the application software, C++ standard library, runtime support, operating system, and hardware platform.

A credible safety case must therefore consider the complete software stack rather than relying on application testing alone. Depending on the project context, confidence can be established through requirements-based testing, structural coverage analysis, static analysis, conformance testing, qualification of tools and software components, independent reviews, and assessments of operational experience.

Conclusion

Conclusion

The reported defect in LLVM Project's implementation of std::async provides an instructive example of the distinction between a specification and the software that implements it. Although the C++ Standard clearly defined the required behavior when thread creation fails, verification activities revealed an implementation defect that could cause an application to hang rather than report the error through the required exception mechanism. The defect was reported by Validas, acknowledged by the LLVM maintainers, and fixed upstream.

For functional safety practitioners, the broader lesson is more significant than the defect itself. Confidence in safety-related software cannot be derived solely from the existence of standards, the reputation of a technology, or the widespread adoption of a software component. Instead, confidence must be built through evidence-based verification of the actual implementations that form part of the deployed system.

Refererences

Refererences