TUM Logo

Optimizing MemorySanitizer Instrumentation using Static Analysis

Optimizing MemorySanitizer Instrumentation using Static Analysis

Supervisor(s): Benjamin Orthen, Julian Horsch
Status: finished
Topic: Others
Author: Yannic Hampel
Submission: 2025-10-01
Type of Thesis: Bachelorthesis
Thesis topic in co-operation with the Fraunhofer Institute for Applied and Integrated Security AISEC, Garching

Description

MemorySanitizer (MSan ) is a tool for detecting the use of uninitialized memory during
runtime. One of its major drawbacks is the significant slowdown in runtime: on average,
programs run 2.11 times slower with MSan . To improve MSan ’s performance, this thesis
examines its components to identify optimization opportunities. Four optimizations
are presented: three static analyses and one general optimization. All of these focus
on the MSan instrumentation. Two of the analyses identify instrumentation variables
in MSan that can be replaced with constants, which the compiler can then simplify.
The other two optimizations simplify MSan ’s instrumentation, reducing the number of
instructions MSan requires to detect errors in a program. One analysis reduces MSan ’s
slowdown by 0.7%, excluding one significant outlier. The most effective optimization
reduces MSan ’s average slowdown by 4.3% and speeds up programs by 3.8%, albeit at
the cost of more false positives. Otherwise, the slowdowns remain relatively unchanged.
The optimizations introduce no false negatives, though two can introduce new false
positives.