Skip to content

Commit

Permalink
make sure all compiler tests are run with VM in paranoid mode (aptos-…
Browse files Browse the repository at this point in the history
…labs#13051)

* enable paranoid mode for VM in transactional tests
* tested by triggering paranoid-mode failure on all transactional test frameworks
  • Loading branch information
brmataptos authored May 1, 2024
1 parent f265820 commit 1af48e9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ impl<'a> MoveTestAdapter<'a> for AptosTestAdapter<'a> {
pre_compiled_deps_v2: Option<&'a PrecompiledFilesModules>,
task_opt: Option<TaskInput<(InitCommand, Self::ExtraInitArgs)>>,
) -> (Self, Option<String>) {
AptosVM::set_paranoid_type_checks(true);
// Named address mapping
let additional_named_address_mapping = match task_opt.as_ref().map(|t| &t.command) {
Some((InitCommand { named_addresses }, _)) => {
Expand Down Expand Up @@ -1031,5 +1032,6 @@ pub fn run_aptos_test_with_config(
};
let v1_lib = precompiled_v1_stdlib_if_needed(&config);
let v2_lib = precompiled_v2_stdlib_if_needed(&config);
AptosVM::set_paranoid_type_checks(true);
run_test_impl::<AptosTestAdapter>(config, path, v1_lib, v2_lib, &None)
}
11 changes: 11 additions & 0 deletions third_party/move/move-binary-format/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@ impl PartialVMError {
indices,
offsets,
} = *self.0;
let bt = std::backtrace::Backtrace::capture();
let message = if std::backtrace::BacktraceStatus::Captured == bt.status() {
if let Some(message) = message {
Some(format!("{}\nBacktrace: {:#?}", message, bt).to_string())
} else {
Some(format!("Backtrace: {:#?}", bt).to_string())
}
} else {
message
};

VMError(Box::new(VMError_ {
major_status,
sub_status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn main() {
.flatten()
.filter_map(|e| {
let p = e.path().display().to_string();
if p.ends_with(".move") {
if p.ends_with(".move") || p.ends_with(".mvir") {
Some(p)
} else {
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ Error: Script execution failed with VMError: {
offsets: [],
}

task 2 'run'. lines 30-39:
Error: Script execution failed with VMError: {
major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR,
sub_status: Some(1),
location: undefined,
indices: [],
offsets: [],
}

task 3 'run'. lines 41-50:
Error: Script execution failed with VMError: {
major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR,
Expand All @@ -20,8 +29,8 @@ Error: Script execution failed with VMError: {

task 4 'run'. lines 52-61:
Error: Script execution failed with VMError: {
major_status: INTERNAL_TYPE_ERROR,
sub_status: None,
major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR,
sub_status: Some(1),
location: undefined,
indices: [],
offsets: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ Error: Script execution failed with VMError: {
indices: [],
offsets: [],
}

task 2 'run'. lines 30-39:
Error: Script execution failed with VMError: {
major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR,
sub_status: Some(1),
location: undefined,
indices: [],
offsets: [],
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ Error: Script execution failed with VMError: {
indices: [],
offsets: [(FunctionDefinitionIndex(0), 2)],
}

task 3 'run'. lines 39-49:
Error: Script execution failed with VMError: {
major_status: UNKNOWN_INVARIANT_VIOLATION_ERROR,
sub_status: Some(1),
location: 0x2::Math,
indices: [],
offsets: [(FunctionDefinitionIndex(0), 2)],
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub struct AdapterPublishArgs {

#[derive(Debug, Parser)]
pub struct AdapterExecuteArgs {
#[clap(long)]
#[clap(long, default_value = "true")]
pub check_runtime_types: bool,
/// print more complete information for VMErrors on run
#[clap(long)]
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> MoveTestAdapter<'a> for SimpleVMTestAdapter<'a> {
}
Ok(())
},
VMConfig::production(),
production_vm_config_with_paranoid_type_checks(),
)
.unwrap();
let mut addr_to_name_mapping = BTreeMap::new();
Expand Down Expand Up @@ -250,7 +250,7 @@ impl<'a> MoveTestAdapter<'a> for SimpleVMTestAdapter<'a> {
compat,
)
},
VMConfig::production(),
production_vm_config_with_paranoid_type_checks(),
) {
Ok(()) => Ok((None, module)),
Err(vm_error) => Err(anyhow!(
Expand Down Expand Up @@ -559,3 +559,10 @@ impl From<AdapterExecuteArgs> for VMConfig {
}
}
}

fn production_vm_config_with_paranoid_type_checks() -> VMConfig {
VMConfig {
paranoid_type_checks: true,
..VMConfig::production()
}
}

0 comments on commit 1af48e9

Please sign in to comment.