Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ impl SharedTestingConfig {
arguments,
);

if !self.report_stacktrace_on_abort && let Err(err) = &mut return_result {
if !self.report_stacktrace_on_abort
&& let Err(err) = &mut return_result
{
err.remove_exec_state();
}

Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-vm-config/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::verifier::{VerifierConfig, DEFAULT_MAX_CONSTANT_VECTOR_LEN};
use crate::verifier::{DEFAULT_MAX_CONSTANT_VECTOR_LEN, VerifierConfig};
use move_binary_format::binary_config::BinaryConfig;
use move_binary_format::file_format_common::VERSION_MAX;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,18 @@ fn step(
let fun_ref = state.call_stack.current_frame.function();
let instructions = fun_ref.code();
let pc = state.call_stack.current_frame.pc as usize;
assert!(
pc <= instructions.len(),
"PC beyond instruction count for {}",
fun_ref.name(&run_context.vtables.interner)
);
if pc >= instructions.len() {
return Err(
state.set_location(
PartialVMError::new(StatusCode::PC_OVERFLOW).with_message(format!(
"PC {} out of bounds for function {} with {} instructions",
pc,
fun_ref.name(&run_context.vtables.interner),
instructions.len()
)),
),
);
}
let instruction = &instructions[pc];
fail_point!("move_vm::interpreter_loop", |_| {
Err(state.set_location(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,12 @@ impl GlobalValueImpl {
return Err(PartialVMError::new(StatusCode::MISSING_DATA));
}
Self::Filled(container) => {
assert!(matches!(self, Self::Empty));
if !matches!(self, Self::Empty) {
return Err(
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
.with_message("global value is not empty".to_string()),
);
}
container
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,20 @@ pub fn package(
let loaded_module = module(&mut package_context, version_id, &mut input_module)?;

let key = interner.intern_ident_str(loaded_module.id.name())?;
assert!(
package_context
.loaded_modules
.insert(key, loaded_module)
.is_none()
);
if package_context
.loaded_modules
.insert(key, loaded_module)
.is_some()
{
return Err(
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR).with_message(
format!(
"Duplicate module loaded in package {}",
package_context.version_id
),
),
);
}
}

let PackageContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,42 @@ pub(crate) fn package(vm_config: &VMConfig, pkg: SerializedPackage) -> VMResult<
for (mname, module) in pkg.modules.iter() {
let module = CompiledModule::deserialize_with_config(module, &vm_config.binary_config)
.map_err(|err| err.finish(Location::Package(pkg.version_id)))?;

// The name of the module in the mapping, and the name of the module itself should be equal
assert_eq!(mname.as_ident_str(), module.self_id().name());
if mname.as_ident_str() != module.self_id().name() {
return Err(
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
.with_message(format!(
"Module name mismatch: mapping has '{}', module has '{}'",
mname.as_ident_str(),
module.self_id().name()
))
.finish(Location::Package(pkg.version_id)),
);
}

assert_eq!(
module.address(),
&original_id,
"Module address does not match package original ID"
);
// The address of the module must match the original package ID
if module.address() != &original_id {
return Err(
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR)
.with_message(format!(
"Module address mismatch: expected '{}', found '{}'",
original_id,
module.address()
))
.finish(Location::Package(pkg.version_id)),
);
}

// Impossible for a package to have two modules with the same name at this point.
assert!(modules.insert(module.self_id(), module).is_none());
if modules.insert(module.self_id(), module).is_some() {
return Err(PartialVMError::new(StatusCode::DUPLICATE_MODULE_NAME)
.with_message(format!(
"Duplicate module name found: '{}'",
mname.as_ident_str()
))
.finish(Location::Package(pkg.version_id)));
}
}

// Packages must be non-empty
Expand Down
Loading