Add macOS support for AddressSanitizer memory limit (#7308)
This commit is contained in:
parent
b9c8560d12
commit
ee7ec08cf5
|
|
@ -213,6 +213,13 @@ sub ulimit_stack_unlimited {
|
||||||
# AddressSanitizer doesn't work with 'ulimit -s unlimted'
|
# AddressSanitizer doesn't work with 'ulimit -s unlimted'
|
||||||
if (`${\(verilator_bin())} --get-supported DEV_ASAN` eq "1\n") {
|
if (`${\(verilator_bin())} --get-supported DEV_ASAN` eq "1\n") {
|
||||||
# Use host 'physical memory / #cores / 8' instead
|
# Use host 'physical memory / #cores / 8' instead
|
||||||
|
if ($^O eq "darwin") {
|
||||||
|
my $membytes = `sysctl -n hw.memsize`;
|
||||||
|
chomp $membytes;
|
||||||
|
my $ncpu = `sysctl -n hw.ncpu`;
|
||||||
|
chomp $ncpu;
|
||||||
|
$limit = int(int($membytes / 1024) / $ncpu / 8);
|
||||||
|
} else {
|
||||||
open(my $fh, "<", "/proc/meminfo") || die "Can't read host memory for asan";
|
open(my $fh, "<", "/proc/meminfo") || die "Can't read host memory for asan";
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
if (m/MemTotal:\s+(\d+)\s+kB/) {
|
if (m/MemTotal:\s+(\d+)\s+kB/) {
|
||||||
|
|
@ -222,6 +229,7 @@ sub ulimit_stack_unlimited {
|
||||||
}
|
}
|
||||||
close($fh);
|
close($fh);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
system("ulimit -s $limit 2>/dev/null");
|
system("ulimit -s $limit 2>/dev/null");
|
||||||
my $status = $?;
|
my $status = $?;
|
||||||
if ($status == 0) {
|
if ($status == 0) {
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,7 @@ Lukasz Dalek
|
||||||
Maarten De Braekeleer
|
Maarten De Braekeleer
|
||||||
Maciej Sobkowski
|
Maciej Sobkowski
|
||||||
Marcel Chang
|
Marcel Chang
|
||||||
|
Marco Bartoli
|
||||||
Marco Widmer
|
Marco Widmer
|
||||||
Mariusz Glebocki
|
Mariusz Glebocki
|
||||||
Markus Krause
|
Markus Krause
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue