External Analysis Tools

TEMU can be run under external memory analysis tools such as Valgrind and sanitizer-enabled builds. There are two tool-specific interactions that are worth knowing about when interpreting reports.

Valgrind and Binary Translation

TEMU’s binary translator emits host code at run time. On x86 hosts this generated code may use the host flag save and restore instructions PUSHFW/POPFW. Before Valgrind 3.3.1, the instructions in question were not properly supported.

If Valgrind fails while executing translated code, use a newer Valgrind build. If upgrading Valgrind is not possible, disable binary translation while running under Valgrind.

# Disable binary translation on a specific SPARC processor.
cpu0.disableTranslation

# Disable binary translation on a specific RISC-V processor.
cpu0.disable-dbt

Disabling binary translation reduces performance, but keeps execution on the interpreter path that is easier for Valgrind to instrument.

Process-Lifetime Allocations

Some TEMU support systems intentionally keep small global data structures alive until process exit. For example, the notification system keeps its global notification tables and synchronization objects allocated for the lifetime of the process. This avoids static destruction order problems during normal shutdown, where objects may still emit disposal notifications while other global objects are being torn down.

If integrating TEMU with LeakSanitizer compiled simulators or tools, then the notification system may trigger detection of leaks.

These can typically be suppressed as follows:

LSAN_OPTIONS=suppressions=/path/to/temu-lsan.supp ./my-simulator

Where the suppression file contains the following:

leak:notificationNameMap
leak:notificationMap
leak:libTEMUSupport

Similarly, when using Valgrind, these allocations may be seen as still reachable, especially when run with --show-leak-kinds=all. Such entries are expected and should not be treated as leaks, and may need suppression.