dwrensha / seer

symbolic execution engine for Rust
Other
345 stars 7 forks source link

can't handle type X with layout General { ... } #2

Closed dwrensha closed 7 years ago

dwrensha commented 7 years ago

Consider the following program.

enum Token {
    _LeftAngle,
    _RightAngle
}

struct Failures<P> {
    _point: P,
}

struct ParseMaster<P> {
    _failures: Failures<P>,
}

struct Alternate<'pm, P: 'pm, T> {
    _master: &'pm mut ParseMaster<P>,
    _current: Option<Progress<P, T>>,
    _point: P,
}

struct TokenPoint<'a, T: 'a> {
    _offset: usize,
    _sub_offset: Option<u8>,
    _s: &'a [T],
}

impl <P> ParseMaster<P> {
    fn alternate<'pm, T>(&'pm mut self, pt: P) -> Alternate<'pm, P, T> {
        Alternate {
            _master: self,
            _current: None,
            _point: pt,
        }
    }
}

struct Progress<P, T> {
    _point: P,
    _status: Status<T>,
}

enum Status<T> {
    _Success(T),
    _Failure,
}

fn main() {
    let mut pm : ParseMaster<TokenPoint<Token>> = ParseMaster {
        _failures: Failures {
            _point: TokenPoint {
                _offset: 0,
                _sub_offset: None,
                _s:&[],
            },
        },
    };

    pm.alternate::<()>(TokenPoint {
        _offset: 0,
        _sub_offset: None,
        _s:&[],
    });

}

I expect seer to be able to run this program successfully. Indeed, miri has no problem running it. However, seer returns an error:

Unimplemented("can\'t handle type: std::option::Option<u8>, with layout: General { discr: I8, variants: [Struct { align: Align { abi: 0, pref: 3 }, primitive_align: Align { abi: 0, pref: 3 }, packed: false, sized: true, offsets: [Size { raw: 0 }], memory_index: [0], min_size: Size { raw: 1 } }, Struct { align: Align { abi: 0, pref: 3 }, primitive_align: Align { abi: 0, pref: 3 }, packed: false, sized: true, offsets: [Size { raw: 0 }, Size { raw: 1 }], memory_index: [0, 1], min_size: Size { raw: 2 } }], size: Size { raw: 2 }, align: Align { abi: 0, pref: 3 }, primitive_align: Align { abi: 0, pref: 3 } }")
dwrensha commented 7 years ago

Fixed by https://github.com/dwrensha/seer/commit/bcd0cdb569c99ea64e2146e75ea06880c9476c6b.

Was fixed in miri by https://github.com/solson/miri/pull/284