Skip to content

Commit

Permalink
tests: disable ASLR for t_trace_ub_misaligned_address
Browse files Browse the repository at this point in the history
This works around an address-sanitizer bug hit with some GCC versions
  • Loading branch information
gezalore committed Apr 29, 2024
1 parent 8ed269c commit 0c2633c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test_regress/driver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,19 @@ sub cmake_version {
return version->declare($cmake_version);
}

our $_aslr_off = undef;
sub aslr_off {
if (!defined($_aslr_off)) {
my $ok = `setarch --addr-no-randomize echo ok 2>/dev/null` || "";
if ($ok =~ /ok/) {
$_aslr_off = "setarch --addr-no-randomize ";
} else {
$_aslr_off = "";
}
}
return $_aslr_off;
}

sub trace_filename {
my $self = shift;
return "$self->{obj_dir}/simx.fst" if $self->{trace_format} =~ /^fst/;
Expand Down Expand Up @@ -1670,6 +1683,7 @@ sub _run {
my $self = (ref $_[0] ? shift : $Self);
my %param = (tee => 1,
# cmd => [...]
# aslr_off => # Disable address space layour randomization
# check_finished => 0 # Check for All Finished
# entering => # Print entering directory information
# expect => # Regexp to expect in output
Expand All @@ -1680,6 +1694,13 @@ sub _run {
@_); # All legal arguments shown immediately above

my $command = join(' ', @{$param{cmd}});

if ($param{aslr_off}) {
if (my $prefix = aslr_off()) {
$command = "$prefix $command";
}
}

$command = "time $command" if $opt_benchmark && $command !~ /^cd /;

if ($param{verilator_run}) {
Expand Down
1 change: 1 addition & 0 deletions test_regress/t/t_trace_ub_misaligned_address.pl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

execute(
check_finished => 1,
aslr_off => 1, # Some GCC versions hit an address-sanitizer bug otherwise
);

# Make sure that there are no additional messages (such as runtime messages
Expand Down

0 comments on commit 0c2633c

Please sign in to comment.