Open mateon1 opened 7 years ago
Thanks a lot for this great report :)
Here's code that triggers this crash: [Note: I use boxed traits, because the jit!() macro doesn't accept generic functions]
Yes, this is a problem which is due to the fact that we would have to re-implement the elision for the jit!
macro, as it stores the signature of the function in a structure.
I looked at the crash for a bit in rr, it seems that something is calling index_mut without setting registers properly.
At the moment the assembly output is quite similar to the -O0 of LLVM, except for the fact that HolyJit does not yet use the ModRm addressing modes. You should be (almost) able to compare the assembly produced by HolyJit with the result of:
(rr) disas brainfuck::eval_impl
Looking at the generated code, it seems that the problem is that instead of giving the Range argument by reference, we give it by value to the index_mut
function:
0x7f2fef121dc6 mov (%rsi),%rdi
0x7f2fef121dc9 movabs $0xfffffffffffffd68,%rsi
0x7f2fef121dd3 add %rbp,%rsi
0x7f2fef121dd6 mov (%rsi),%rax
0x7f2fef121dd9 mov 0x8(%rsi),%rcx
0x7f2fef121ddd mov %rax,%rsi
0x7f2fef121de0 mov %rdx,%rax
0x7f2fef121de3 mov %rcx,%rdx
0x7f2fef121de6 callq *%rax
The problem is likely located here: https://github.com/nbp/holyjit/blob/e4ed3be729ae91c5aa8ce93ca0c648afb642feb9/plugin/src/trans.rs#L1083-L1093
I came across this while trying to implement input/output for brainfuck. I looked at the crash for a bit in rr, it seems that something is calling index_mut without setting registers properly.
rsi = 0x0
, which causes a null derefIn short:
So this is definitely crashing on indexing the
mem
variable.Here's code that triggers this crash: [Note: I use boxed traits, because the
jit!()
macro doesn't accept generic functions]