ZoKrates
ZoKrates copied to clipboard
Out-of-bounds access crashes the static analyser
def main():
u32[16] memory = [0; 16]
memory[17] = 1
return
Compiling bug1.zok
index out of bounds: the len is 16 but the index is 17 (/Users/alex/Projects/ZoKrates/zokrates_core/src/static_analysis/propagation.rs:85:77)
This is unexpected, please submit a full bug report at https://github.com/Zokrates/ZoKrates/issues
I was actually preparing a short example for a different bug and tried to simplify the code, so I found this issue too.
Right, this needs to be handled more gracefully.
Interestingly, static analysis handles the write case:
def main():
u32[16] memory = [0; 16]
u32 f = memory[17]
return
$ zz compile -i bug.zok
Compiling bug.zok
Compilation failed:
bug.zok:
Out of bounds index (17 >= 16) found during static analysis
This was fixed a while back, just didn't close this issue.