$ use Getopt::Long;
use File::Path 'mkpath'; GetOptions('asan-on-linux' => \my $asan_on_linux); my @ccflags;
my @ldflags;
my $asan_logs_dir = ".tmp/asan_logs"; if ($asan_on_linux) { push @ccflags, "-fsanitize=address", "-fno-omit-frame-pointer"; push @ldflags, "-fsanitize=address"; mkpath $asan_logs_dir unless -d $asan_logs_dir;
}
use Getopt::Long;
use File::Path 'mkpath'; GetOptions('asan-on-linux' => \my $asan_on_linux); my @ccflags;
my @ldflags;
my $asan_logs_dir = ".tmp/asan_logs"; if ($asan_on_linux) { push @ccflags, "-fsanitize=address", "-fno-omit-frame-pointer"; push @ldflags, "-fsanitize=address"; mkpath $asan_logs_dir unless -d $asan_logs_dir;
}
use Config; WriteMakefile( NAME => 'My::Module', CCFLAGS => "$Config{ccflags} " . join(' ', @ccflags), LDDLFLAGS => "$Config{lddlflags} " . join(' ', @ldflags), # ... macro => { $asan_on_linux ? ( 'override FULLPERL' => qq|LD_PRELOAD=\$\$($Config{cc} -print-file-name=libasan.so) ASAN_OPTIONS="log_path=$asan_logs_dir/asan.log:exitcode=0" $^X| ) : (), },
);
use Config; WriteMakefile( NAME => 'My::Module', CCFLAGS => "$Config{ccflags} " . join(' ', @ccflags), LDDLFLAGS => "$Config{lddlflags} " . join(' ', @ldflags), # ... macro => { $asan_on_linux ? ( 'override FULLPERL' => qq|LD_PRELOAD=\$\$($Config{cc} -print-file-name=libasan.so) ASAN_OPTIONS="log_path=$asan_logs_dir/asan.log:exitcode=0" $^X| ) : (), },
);
perl -00 -ne 'print "--- File: $ARGV ---\n$_\n" if /My::Module/' .tmp/asan_logs/* > .tmp/asan_summary.log
perl -00 -ne 'print "--- File: $ARGV ---\n$_\n" if /My::Module/' .tmp/asan_logs/* > .tmp/asan_summary.log - Memory Corruption: Issues like buffer overflows or use-after-free will cause a Segmentation Fault (Segfault) immediately. When this happens, you must fix the code until all tests pass without crashing.
- Memory Leaks: Unlike corruption, memory leaks do not cause a crash. To find them, you must check the logs after running your tests.