You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
MIRAI tag analysis would fail unexpectedly when analyzing container types, e.g., Vec, user-defined structs.
Steps to Reproduce
Source code:
#![cfg_attr(mirai, allow(incomplete_features), feature(generic_const_exprs))]#[macro_use]externcrate mirai_annotations;#[cfg(mirai)]use mirai_annotations::*;#[cfg(mirai)]structSecretTaintKind<constMASK:TagPropagationSet>{}constMASK:TagPropagationSet = TAG_PROPAGATION_ALL;#[cfg(mirai)]typeSecretTaint = SecretTaintKind<MASK>;#[cfg(not(mirai))]typeSecretTaint = ();// Ensures code compiles in non-MIRAI buildsfnfoo(v:&Vec<i32>){// This precondition should never be true.precondition!(does_not_have_tag!(&v[0], SecretTaint) && has_tag!(&v[0], SecretTaint));}fnbar(v:&i32){precondition!(does_not_have_tag!(v, SecretTaint));}fnmain(){let v = vec![1, 2, 3];add_tag!(&v, SecretTaint);foo(&v);}
The output is given as follows.
$ cargo mirai
Checking playground v0.1.0 (/home/kali/playground)
warning: unused `#[macro_use]` import
--> src/main.rs:3:1
|
3 |#[macro_use]| ^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: `playground` (bin "playground") generated 1 warnings
Finished dev [unoptimized + debuginfo] target(s) in 0.36s
(base)
The thing is, MIRAI should give a warning that indicates an unsatisfied precondition but in this case, it failed to do so.
$ cargo mirai
Checking playground v0.1.0 (/home/test/playground)
warning: unused `#[macro_use]` import
--> src/main.rs:3:1
|
3 |#[macro_use]| ^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: `playground` (bin "playground") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.45s
The above code was tested under the newest version of MIRAI (commit SHA fe1b8989371f16f343191b75555fd5fcf06c733a), but when I tested the some older version of MIRAI (commit SHA f3e8dfc1fc8a86216948fe36d0b6488b16dd5b9a), the report on the unsatisfied precondition would appear.
Besides, #1147 mentions failing tag analysis for type transformation, which, I suspect, may be due to internal bugs related to container types. Moreover, MIRAI will give no warning if given the following code snippet:
fnmain(){let a = A(1);add_tag!(&a, SecretTaint);let b = a_to_b(a);// verify!(has_tag!(&b, SecretTaint));let c = b_to_c(b);// verify!(has_tag!(&c, SecretTaint));}
I.e., if verfiy!s are all removed, then MIRAI will not complain about the unsatisfied precondition for b_to_c, but if verify!(has_tag!(&b, SecretTaint)); is uncommented, then MIRAI would do so.
Hope these bugs can be fixed as soon as possible!
Expected Behavior
MIRAI should complain about the unsatisfied precondition for function call foo.
Actual Results
MIRAI generated no information on unsatisfied preconditions for container types.
Environment
rustc 1.65.0-nightly (d394408fb 2022-08-07)
The text was updated successfully, but these errors were encountered:
Issue
MIRAI tag analysis would fail unexpectedly when analyzing container types, e.g.,
Vec
, user-defined structs.Steps to Reproduce
Source code:
The output is given as follows.
The thing is, MIRAI should give a warning that indicates an unsatisfied precondition but in this case, it failed to do so.
The above code was tested under the newest version of MIRAI (commit SHA
fe1b8989371f16f343191b75555fd5fcf06c733a
), but when I tested the some older version of MIRAI (commit SHAf3e8dfc1fc8a86216948fe36d0b6488b16dd5b9a
), the report on the unsatisfied precondition would appear.Besides, #1147 mentions failing tag analysis for type transformation, which, I suspect, may be due to internal bugs related to container types. Moreover, MIRAI will give no warning if given the following code snippet:
I.e., if
verfiy!
s are all removed, then MIRAI will not complain about the unsatisfied precondition forb_to_c
, but ifverify!(has_tag!(&b, SecretTaint));
is uncommented, then MIRAI would do so.Hope these bugs can be fixed as soon as possible!
Expected Behavior
MIRAI should complain about the unsatisfied precondition for function call
foo
.Actual Results
MIRAI generated no information on unsatisfied preconditions for container types.
Environment
rustc 1.65.0-nightly (d394408fb 2022-08-07)
The text was updated successfully, but these errors were encountered: