Merge pull request #1119 from mir-protocol/jacqui/topos-protocol/stack_len_bounds_aux_error

Fix `generate_exception` (#1115 replacement)
This commit is contained in:
Jacqueline Nabaglo 2023-07-10 15:37:21 -04:00 committed by GitHub
commit dca50adfac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -699,7 +699,14 @@ pub(crate) fn generate_exception<F: Field>(
return Err(ProgramError::GasLimitError);
}
row.stack_len_bounds_aux = (row.stack_len + F::ONE).inverse();
let disallowed_len = F::from_canonical_usize(MAX_USER_STACK_SIZE + 1);
let diff = row.stack_len - disallowed_len;
if let Some(inv) = diff.try_inverse() {
row.stack_len_bounds_aux = inv;
} else {
// This is a stack overflow that should have been caught earlier.
return Err(ProgramError::InterpreterError);
}
row.general.exception_mut().exc_code_bits = [
F::from_bool(exc_code & 1 != 0),