Address and thread sanitizer fixes (#250)

* Address and thread sanitizer fixes

- Fix compilation with clang
- Tweak perfetto copy to build tree
- Added suppression files to scripts
- fix LD_PRELOAD support in omnitrace-causal and omnitrace-sample
- use spin_mutex and spin_lock from timemory instead of atomic_mutex and atomic_lock
- state uses atomic
- fix some memory leaks
- tweak testing
  - mpi tests do not use preload
  - increase timeout when using sanitizers
  - add env LD_PRELOAD when using sanitizers

* Tweak perfetto build

* Update timemory submodule

* Update version to 1.8.1

* Update omnitrace-leak.supp

* Update timemory submodule

- fixed spin_mutex implementation

* Remove previously added addr_space->allowTraps(instr_traps)

- this appears to cause errors during binary rewrite

* causal testing updates

- relaxed causal validation on CI systems (to account for hyperthreading decreasing prediction)
- improved impact calculation
- other general improvements to validate-causal-json.py

* Improve fork handling for perfetto

- numerous updates changing perfetto:: to ::perfetto::
- added perfetto_fwd.hpp

* Updated fork example

- user API for validation that stopping/starting perfetto is valid

* Misc fixes to perfetto + fork support

- tweak regions in fork example
- handle disabling tmp files
- get rid of stop/start with perfetto before/after fork
- fixed sampling support during fork
- tweak env of fork test

* Fix find_package in build-tree

* Fix buildtree export

* Fix buildtree export

* Restructured ConfigInstall before adding examples

* Guard against creating tmp file in sampling when disabled

* Fix buildtree package

* formatting

* exit handlers on child processes

- quick exit to avoid perfetto cleanup

* Further tweaking of causal tests for reliability

- enable PROCESSOR_AFFINITY
- decrease to 5 iterations

* Further tweaking of causal tests for reliability

- disable PROCESSOR_AFFINITY for fast func e2e tests
- enabling affinity results in (valid) speedup predictions greater than zero

* Fixes to fork handling

- use pthread_atfork for redundancy if fork_gotcha fails

* cmake formatting

* Fix fork init settings + install components

- remove dl from PROJECT_BUILD_TARGETS

* Testing tweaks

- fix mpi-binary-rewrite-run regex when OMNITRACE_VERBOSE set > 1 in env
- increase causal e2e iterations to 8

* Fix "Test User API"

- test-find-package.sh included dl component

* Further tweaks to causal validation

- further considerations of variance
This commit is contained in:
Jonathan R. Madsen
2023-02-27 12:09:03 -06:00
committed by GitHub
parent 9a665b5684
commit 846301bcaf
48 changed files with 885 additions and 455 deletions
+12 -2
View File
@@ -424,8 +424,18 @@ update_env(std::vector<char*>& _environ, std::string_view _env_var, Tp&& _env_va
{
auto _val = std::string{ itr }.substr(_key.length());
free(itr);
itr = strdup(
join('=', _env_var, join(_join_delim, _env_val, _val)).c_str());
if(_env_var == "LD_PRELOAD")
{
itr =
strdup(join('=', _env_var, join(_join_delim, _val, _env_val))
.c_str());
}
else
{
itr =
strdup(join('=', _env_var, join(_join_delim, _env_val, _val))
.c_str());
}
}
}
else
@@ -97,9 +97,9 @@ namespace
void
init_perfetto()
{
perfetto::TracingInitArgs args{};
perfetto::TraceConfig cfg{};
perfetto::protos::gen::TrackEventConfig track_event_cfg{};
::perfetto::TracingInitArgs args{};
::perfetto::TraceConfig cfg{};
::perfetto::protos::gen::TrackEventConfig track_event_cfg{};
auto shmem_size_hint = config::get_perfetto_shmem_size_hint();
auto buffer_size = config::get_perfetto_buffer_size();
@@ -107,19 +107,19 @@ init_perfetto()
buffer_config->set_size_kb(buffer_size);
buffer_config->set_fill_policy(
perfetto::protos::gen::TraceConfig_BufferConfig_FillPolicy_DISCARD);
::perfetto::protos::gen::TraceConfig_BufferConfig_FillPolicy_DISCARD);
auto* ds_cfg = cfg.add_data_sources()->mutable_config();
ds_cfg->set_name("track_event");
ds_cfg->set_track_event_config_raw(track_event_cfg.SerializeAsString());
args.backends |= perfetto::kInProcessBackend;
args.backends |= ::perfetto::kInProcessBackend;
args.shmem_size_hint_kb = shmem_size_hint;
perfetto::Tracing::Initialize(args);
perfetto::TrackEvent::Register();
::perfetto::Tracing::Initialize(args);
::perfetto::TrackEvent::Register();
tracing_session = perfetto::Tracing::NewTrace();
tracing_session = ::perfetto::Tracing::NewTrace();
tracing_session->Setup(cfg);
tracing_session->StartBlocking();
}
@@ -128,7 +128,7 @@ void
fini_perfetto()
{
// Make sure the last event is closed for this example.
perfetto::TrackEvent::Flush();
::perfetto::TrackEvent::Flush();
OMNITRACE_DEBUG_F("Stopping the blocking perfetto trace sessions...\n");
tracing_session->StopBlocking();
+6 -1
View File
@@ -246,7 +246,12 @@ update_env(std::vector<char*>& _environ, std::string_view _env_var, Tp&& _env_va
{
auto _val = std::string{ itr }.substr(_key.length());
free(itr);
itr = strdup(join('=', _env_var, join(":", _env_val, _val)).c_str());
if(_env_var == "LD_PRELOAD")
itr = strdup(
join('=', _env_var, join(":", _val, _env_val)).c_str());
else
itr = strdup(
join('=', _env_var, join(":", _env_val, _val)).c_str());
}
}
else
+1 -1
View File
@@ -467,7 +467,7 @@ get_internal_libs_data_impl()
file_internal_include))
continue;
verbprintf(2, "[internal] parsing module: '%s' (via '%s')...\n",
verbprintf(3, "[internal] parsing module: '%s' (via '%s')...\n",
_mname.c_str(), filepath::basename(itr.first));
_data[itr.first].emplace(_mpath, func_set_t{});
+3 -1
View File
@@ -347,7 +347,7 @@ main(int argc, char** argv)
if(resolved_mutname != mutname)
{
mutname = resolved_mutname;
delete _cmdv[0];
free(_cmdv[0]);
copy_str(_cmdv[0], resolved_mutname.c_str());
}
}
@@ -1343,6 +1343,8 @@ main(int argc, char** argv)
addr_space =
omnitrace_get_address_space(bpatch, _cmdc, _cmdv, binary_rewrite, _pid, mutname);
// addr_space->allowTraps(instr_traps);
if(!addr_space)
{
errprintf(-1, "address space for dynamic instrumentation was not created\n");