brownsys/paralegal

Control-flow influence isn't captured from callsites that might result in an early error return to downstream fn calls

JustusAdam opened this issue · 0 comments

as a minimal example we have this code and the resulting flows:

#[dfpp::analyze]
  pub fn a(&self, j: i64) -> AtomicResult<i64> {
      self.is_ok()?;
      self.store(j);
      Ok(1)
  }
  fn is_ok(&self) -> AtomicResult<i64> {
      Ok(1)
  }
  fn store(&self, _j: i64) {}

// ANALYSIS RESULT
flow =
        (`a_f25633)->(
            (`cs_branch_dcd647_6afc41)->(`arg0_cs_from_residual_a0b86b_f1f843) +
            (`cs_is_ok_e6d043_6772d0)->(`arg0_cs_branch_dcd647_6afc41) +
            (`fp1_a_f25633)->(`arg1_cs_store_8c2d9d_66aa4) +
            (`cs_from_residual_a0b86b_f1f843)->(`Return) +
            (`fp0_a_f25633)->(`arg0_cs_is_ok_e6d043_6772d0 + `arg0_cs_store_8c2d9d_66aa4))
ctrl_flow =
        (`a_f25633)->(
            none->none)

but then if its not a callsite it shows up as expected, like here:

#[dfpp::analyze]
  pub fn a(&self, i: AtomicResult<i64>, j: i64) -> AtomicResult<i64> {
      i?;
      self.store(j);
      Ok(1)
  }

// ANALYSIS RESULT
flow =
      (`a_f25633)->(
          (`fp1_a_f25633)->(`arg0_cs_branch_dcd647_6772d0) +
          (`cs_from_residual_a0b86b_d03f1b)->(`Return) +
          (`cs_branch_dcd647_6772d0)->(`arg0_cs_from_residual_a0b86b_d03f1b) +
          (`fp0_a_f25633)->(`arg0_cs_store_8c2d9d_b374c0) +
          (`fp2_a_f25633)->(`arg1_cs_store_8c2d9d_b374c0))
  ctrl_flow =
      (`a_f25633)->(
          (`cs_branch_dcd647_6772d0)->(`cs_from_residual_a0b86b_d03f1b + `cs_store_8c2d9d_b374c0))

the ctrl flow should be equivalent between the two cases.