Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Development: Address Sanitizer

Lee Savoie edited this page Mar 31, 2021 · 4 revisions

Address sanitizer is a helpful tool built into gcc that detects memory errors such as buffer overflows and memory leaks. However, it is somewhat tricky to use with Open GEE due to the scons build system. Instructions for building Open GEE with address sanitizer are given below.

These instructions have been tested on Ubuntu 16.04, but you may run into issues on other platforms.

  1. Edit earth_enterprise/src/SConstruct and find the if statement around line 234 that sets linkflags and optflags for the different build types. Find the statements that correspond to your build type and set the flags as follows (you can also specify -Og for optflags to partially optimize the code):

     linkflags = ['-fsanitize=address']
     optflags = ['-g', '-fsanitize=address']
    
  2. The build will fail unless you tell address sanitizer that it should not exit when a leak is found via an environment variable. Scons does not use the environment variables from the shell it is run in, so this must be done directly in scons. In the same SConstruct file, add the line env['ENV']['ASAN_OPTIONS'] = 'halt_on_error=0;detect_leaks=0' at some point after the env variable is created (around line 516). You can remove ;detect_leaks=0' to allow scons to detect memory leaks.

  3. Build and run Open GEE. You may have delete src/NATIVE-* before building to ensure that all binaries are rebuilt. Address sanitizer will print out information about any memory problems it finds. This step works best if you run the fusion command line utilities rather than the Fusion UI.