afonso360 opened PR #3154 from filetest-heaps
to main
:
Hey, this is an initial version of what was discussed in #3136. The design and whether or not its a good idea are still up for debate, but I thought having an initial implementation would help visualizing how this would turn out.
The interpreter doesn't support multiple heaps yet, so we will need to alter
test interpret
once it does.
afonso360 edited PR #3154 from filetest-heaps
to main
:
Hey, this is an initial version of what was discussed in #3136. The design and whether or not its a good idea are still up for debate, but I thought having an initial implementation would help visualizing how this would turn out.
The interpreter doesn't support multiple heaps yet, so we will need to alter
test interpret
once it does.Closes #3136
bjorn3 submitted PR review.
bjorn3 created PR review comment:
Maybe also add information about what is stored at which offset from the vmctx pointer instead of keeping it implicit? For example:
; heap: static, size=0x1000, ptr=vmctx+0 ; heap: dynamic, size=0x1000, ptr=vmctx+16, bound=vmctx+24
or
; heap: static, size=0x1000, ptr=*(vmctx+0) ; heap: dynamic, size=0x1000, ptr=*(vmctx+16), bound=*(vmctx+24)
afonso360 updated PR #3154 from filetest-heaps
to main
.
afonso360 updated PR #3154 from filetest-heaps
to main
.
afonso360 updated PR #3154 from filetest-heaps
to main
.
abrown submitted PR review.
abrown created PR review comment:
- Should this be handling overflow?
- And what changes here if/when #3187 is merged?
- And are we going to reuse this struct when we fuzz CLIF + heaps?
abrown submitted PR review.
abrown created PR review comment:
I think the heaps may be laid out sequentially in memory but I'm not sure about the pointers: if the user writes the following,
; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+16 ; heap: dynamic, size=0x1000, ptr=vmctx+8, bound=vmctx+24
Then do bad things happen?
abrown created PR review comment:
It seems like here, or somewhere, we should be checking the
Function
signature to see if its arguments begin with avmctx
and, if not, emit a useful error like "you need to change your function signature to..."
abrown created PR review comment:
Perhaps this can't be done... enforced by the parser? Maybe the docs should say something about "must be laid out sequentially..."
afonso360 created PR review comment:
If the layout is different from what we expect, we throw an error.
I don't like that this interface gives the user the impression that they can change the offsets. But I think its better than being implicit.
Maybe the docs should say something about "must be laid out sequentially..."
Yeah, I'll update the docs.
afonso360 submitted PR review.
afonso360 submitted PR review.
afonso360 created PR review comment:
Should this be handling overflow?
According to the rust docs, this should always be safe. But even in the event where this goes wrong I would expect the tests to fail with a SIGSEGV. It might be better to change to the
wrapping_add
variant of this function.And what changes here if/when cranelift: Add stack support to the interpreter with virtual addresses #3187 is merged?
We won't be able to do this the same way with the interpreter, it will probably need some refactoring to handle the separate address space. Off the top of my head, I think we can do something like the following:
- Allocate the heaps as usual
- Register each heap with the interpreter
- Request the heap pointers from the interpreter
- Build the
context_struct
with those pointers.And are we going to reuse this struct when we fuzz CLIF + heaps?
I hadn't thought about that, but it actually is an easy way to pass all of this info while fuzzing to the interpreter and the actual compiled target.
For fuzzing I'd like to relax the requirement that
vmctx
is the first argument, but that shouldn't be an issue, since we only check for that in the parser.We may also need to coordinate the heaps with the generated
global_values
in each function. Otherwise I think the fuzzer may have issues generating the correct offsets to get valid heap accesses.I think we should be OK reusing this for fuzzing with the changes to generate the valid pointers for the interpreter.
afonso360 edited PR review comment.
afonso360 updated PR #3154 from filetest-heaps
to main
.
afonso360 requested abrown for a review on PR #3154.
abrown submitted PR review.
afonso360 updated PR #3154 from filetest-heaps
to main
.
abrown merged PR #3154.
Last updated: Dec 23 2024 at 12:05 UTC