Skip to content

Commit

Permalink
i#5733, i#5734: Minor fixes in tests (#5796)
Browse files Browse the repository at this point in the history
Adds -max_trace_size to api.rseq to avoid generating too much trace data,
which may cause us to run out of disk space. The issue on varying run times
(and therefore trace data) is not reproducing now on the Jenkins machine,
but with this change, the trace size comes down to 512K from 130M+ which
is better.

Fixes an issue in the invariant checker that causes a SIGSEGV crash during
error reporting when there's no shard stream available. This came up in the
tool.drcacheoff.rseq test during the check_schedule_data checks that
happen at the very end in print_results of the invariant checker, where
we do not have the shard stream anymore. The invariant error itself is yet
to be debugged (i#5734). For the missing shard stream, we now use a
default stream with manually set ref ordinal.

Issue: #5733, #5734
  • Loading branch information
abhinav92003 authored Dec 19, 2022
1 parent 301f9ed commit 3c598ac
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
19 changes: 16 additions & 3 deletions clients/drcachesim/common/memtrace_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,25 @@ class memtrace_stream_t {
/**
* Implementation of memtrace_stream_t useful for mocks in tests.
*/
class test_memtrace_stream_t : public memtrace_stream_t {
class default_memtrace_stream_t : public memtrace_stream_t {
public:
virtual ~test_memtrace_stream_t()
default_memtrace_stream_t()
: record_ordinal_(nullptr)
{
}
default_memtrace_stream_t(uint64_t *record_ordinal)
: record_ordinal_(record_ordinal)
{
}
virtual ~default_memtrace_stream_t()
{
}
uint64_t
get_record_ordinal() const override
{
return 0;
if (record_ordinal_ == nullptr)
return 0;
return *record_ordinal_;
}
uint64_t
get_instruction_ordinal() const override
Expand Down Expand Up @@ -178,5 +188,8 @@ class test_memtrace_stream_t : public memtrace_stream_t {
{
return 0;
}

private:
uint64_t *record_ordinal_;
};
#endif /* _MEMTRACE_STREAM_H_ */
2 changes: 1 addition & 1 deletion clients/drcachesim/tests/record_filter_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class test_record_filter_t : public dynamorio::drmemtrace::record_filter_t {
std::vector<trace_entry_t> output;
};

class local_stream_t : public test_memtrace_stream_t {
class local_stream_t : public default_memtrace_stream_t {
public:
uint64_t
get_last_timestamp() const override
Expand Down
2 changes: 1 addition & 1 deletion clients/drcachesim/tests/view_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class view_nomod_test_t : public view_t {
std::string
run_test_helper(view_t &view, const std::vector<memref_t> &memrefs)
{
class local_stream_t : public test_memtrace_stream_t {
class local_stream_t : public default_memtrace_stream_t {
public:
local_stream_t(view_t &view, const std::vector<memref_t> &memrefs)
: view_(view)
Expand Down
4 changes: 4 additions & 0 deletions clients/drcachesim/tools/invariant_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ invariant_checker_t::check_schedule_data()
// Check that the scheduling data in the files written by raw2trace match
// the data in the trace.
per_shard_t global;
// Use a synthetic stream object to allow report_if_false to work normally.
auto stream = std::unique_ptr<memtrace_stream_t>(
new default_memtrace_stream_t(&global.ref_count_));
global.stream = stream.get();
std::vector<schedule_entry_t> serial;
std::unordered_map<uint64_t, std::vector<schedule_entry_t>> cpu2sched;
for (auto &shard_keyval : shard_map_) {
Expand Down
3 changes: 2 additions & 1 deletion suite/tests/linux/rseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,8 @@ main()
if (register_rseq()) {
#ifdef RSEQ_TEST_ATTACH
/* Set -offline to avoid trying to open a pipe to a missing reader. */
if (setenv("DYNAMORIO_OPTIONS", "-stderr_mask 0xc -client_lib ';;-offline'",
if (setenv("DYNAMORIO_OPTIONS",
"-stderr_mask 0xc -client_lib ';;-offline -max_trace_size 256K'",
1 /*override*/) != 0)
return 1;
/* Create a thread that sits in the rseq region, to test attaching and detaching
Expand Down

0 comments on commit 3c598ac

Please sign in to comment.