-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fault on heap accesses around 0 #204
Comments
This is something C++ devs (myself included) really want. I agree that many uses may not want this so I've been assuming it would be a module-level opt-in flag. I think the ideal is we make this part of the semantics, but currently I don't see a strategy that has full performance if the engine isn't able to use memory-protect+signal-handling tricks to guard the low memory region. (The best I can think of requires an extra |
I like the |
Do you mean in the engine impl or exposing |
I mean 4. that I wrote above. I don't think we need shadow memory for it: we can limit what parameters we allow to |
@jfbastien Right, but how would that be implemented in the engine without either signal-handler support or some shadow memory bookkeeping? That being said, most platforms do seem to have pretty good signal support; I'm mostly recalling a concern of @pizlonator with making JSC embeddable. Filip: have you considered catching faults at the Mach exception layer? That's what we had to do to catch SIGSEGVs before breakpad killed the process; specifically, listening to the thread-level exception ports lets you get first dibs before all the Unix signals run and my impression from the general lack of documentation is that few devs use Mach exceptions directly. |
Hmm, the polyfill may be an issue! I also hadn't thought about engines which can't just use signals... That'll bite them once wasm does support signals, so maybe it's fine to address this issue now? |
On Fri, Jun 19, 2015 at 2:29 AM, JF Bastien [email protected]
We could combine all memory accesses into one kind of addressing mode that load/store base, offset, disp Where "base" is an int32/int64 expression, "offset" is a int32 literal, and I didn't think through the details of whether the two checks could be This requires that all heap accesses have three operands, which is OK if we
|
It’s also a philosophical concern. I prefer for webasm to be specified in such a way that you can create a performant implementation without relying on the OS.
Yeah, the way to program with Mach is to try to find sample code and then just sort of do what that does. ;-) It’s true that this is what we would do, if webasm required us to do it. -Filip |
Then the performance ends up being roughly the same as doing:
Because the subtract is one cycle, but so is a second compare/branch that the CPU can fuse. Either way, adding one cycle is probably not great.
|
That’s true, but this significantly complicates things just for faulting on zero. Faulting on zero feels too much like a developer feature.
But then we risk some wasm generators abusing the 0-offset encoding and using normal math to compute offsets.
|
Since we're planning on having |
So the consensus is that MVP will not fault on nullptr deref? |
The difference between this issue and |
I'd like to see the runtime being able to pass a start_of_usable_memory and for any access below this to optionally fault on MVP. If only to future proof MVP targeted applications. I believe this would address this issue too. |
@jfbastien Once we have @JSStats - Moving linear memory to absolute zero in the virtual address space can be discussed in #334. |
This feature is now being worked on in the memory-control proposal. |
@titzer suggested that "a module may optionally define that out-of-bounds includes small indices close to
0
". I like the idea, and I think we should figure out the details of how this works. C/C++ certainly care about this features, but other languages may not so it may be interesting to let the .wasm file control this.mprotect
, by the developer? Note that toolchains could do this automatically when generating_start
.In all cases, should we mandate that implementations provide information on smallest page size, so that this can be efficiently implemented through memory protection?
The text was updated successfully, but these errors were encountered: