Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Uninitialized access succeeds #13

Open
jacereda opened this issue Feb 6, 2020 · 5 comments · Fixed by #30
Open

Uninitialized access succeeds #13

jacereda opened this issue Feb 6, 2020 · 5 comments · Fixed by #30
Labels
inconsistent prover doesn't match C behaviour need-realworld-feedback feedback from users needed on how the decision would affect real world use
Milestone

Comments

@jacereda
Copy link

jacereda commented Feb 6, 2020

Shouldn't this fail?

https://github.com/aep/zz/blob/5662bdc311d8dd54585a3f43a580eb6d25d516fc/tests/mustpass/branch_dont_loose_deref/src/main.zz#L19

@aep
Copy link
Collaborator

aep commented Feb 6, 2020

maybe

i'm not sure what a good semantic for uninitialized values is.

should zz simply always emit initialization into the C code? (consistent with rust)
should it make uninitialized access illegal? (consistent with probably all C guidelines)
should only branching on uninitialized be illegal (consistent with valgrind)
should it assert an unknown value? (consistent with actual behavior)

it currently does the last one, so using the value in other assertions will fail, but reading it is fine.

@aep aep added inconsistent prover doesn't match C behaviour need-realworld-feedback feedback from users needed on how the decision would affect real world use labels Feb 6, 2020
@jacereda
Copy link
Author

jacereda commented Feb 6, 2020

I guess most C programmers would probably expect the second option. Most C compilers will emit a warning when accessing an unitialized value. I would expect the output to compile without warnings.

@aep
Copy link
Collaborator

aep commented Feb 6, 2020

I would expect the output to compile without warnings.

right, that's a really good basis for these decisions.

@aep
Copy link
Collaborator

aep commented Feb 6, 2020

ok then more decisions to be made.

  1. implement as first class some( ) theory
    advantage: can override it with static_attest(some(it))
    advantage: more expressive and people can come up with other insane use cases for it
    advantage: could be merged with safe( ) so that some( ) is valid for any value except 0 if its a pointer
    disadvantage: massive compile time impact of about +50%

  2. implement as hard error in the symbolic execution phase
    advantage: basically no performance impact
    advantage: there is actually no use case for uninitialized access anyway, unless its a register.
    disadvantage: cannot be overwritten by the user

@icosahedron
Copy link

icosahedron commented Feb 6, 2020

Sounds like the decision should be a flag. :) I would vote that #2 be the default since it's "safer", with a flag to handle the first case if wanted?

@aep aep mentioned this issue Feb 14, 2020
4 tasks
aep added a commit that referenced this issue Mar 16, 2020
@aep aep added this to the 0.1 milestone Mar 16, 2020
@aep aep closed this as completed in #30 Mar 16, 2020
aep added a commit that referenced this issue Mar 16, 2020
@aep aep reopened this Mar 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
inconsistent prover doesn't match C behaviour need-realworld-feedback feedback from users needed on how the decision would affect real world use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants