Itoyori  v0.0.1
util.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ityr/common/util.hpp"
6 
7 namespace ityr::ito {
8 
9 // Check if address space layout randomization (ASLR) is disabled
10 class aslr_checker {
11 public:
13  void* addr = get_static_local_var_addr();
14  void* addr0 = common::mpi_bcast_value(addr, 0, common::topology::mpicomm());
15  int ok = addr == addr0;
17  if (common::topology::my_rank() == 0 &&
18  ok_sum != common::topology::n_ranks()) {
19  common::die("Error: address space layout randomization (ASLR) seems enabled.\n"
20  "To disable ASLR, please run your program with:\n"
21  " $ mpiexec setarch $(uname -m) --addr-no-randomize [COMMANDS]...\n");
22  }
23  }
24 
25  aslr_checker(const aslr_checker&) = delete;
26  aslr_checker& operator=(const aslr_checker&) = delete;
27 
30 
31 private:
32  static void* get_static_local_var_addr() {
33  static int var = 0;
34  return &var;
35  }
36 };
37 
38 }
Definition: util.hpp:10
aslr_checker & operator=(aslr_checker &&)=delete
aslr_checker & operator=(const aslr_checker &)=delete
aslr_checker(aslr_checker &&)=delete
aslr_checker(const aslr_checker &)=delete
aslr_checker()
Definition: util.hpp:12
rank_t n_ranks()
Definition: topology.hpp:208
MPI_Comm mpicomm()
Definition: topology.hpp:206
rank_t my_rank()
Definition: topology.hpp:207
T mpi_bcast_value(const T &value, int root_rank, MPI_Comm comm)
Definition: mpi_util.hpp:145
T mpi_reduce_value(const T &value, int root_rank, MPI_Comm comm, MPI_Op op=MPI_SUM)
Definition: mpi_util.hpp:170
Definition: aarch64.hpp:5