Stream: git-wasmtime

Topic: wasmtime / PR #1357 Expand `Memory` docs and add examples


view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:15):

alexcrichton opened PR #1357 from doc-memory to master:

Try to thoroughly document unsafety of Memory and how it can be used
safely.

cc #1272

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:24):

bjorn3 created PR Review Comment:

/// ```no_run
/// # use wasmtime::Memory;
/// # let mem: &Memory = (|| loop {})();

You can then remove the wrapper function below.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:24):

bjorn3 submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:25):

bjorn3 edited PR Review Comment.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen created PR Review Comment:

/// It's worth also, however, covering some examples of **incorrect**, **unsafe** usage of `Memory`. Do not do these things!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen created PR Review Comment:

:heart:

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen created PR Review Comment:

/// * Long-lived pointers are only valid if `Memory` isn't used in an unsafe way

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:29):

fitzgen created PR Review Comment:

///   shared borrows to overlap with each other, but mutable borrows must overlap

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:38):

alexcrichton submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:38):

alexcrichton created PR Review Comment:

Ah this was intentional since I wanted to explicitly name the functions in different examples.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:39):

alexcrichton updated PR #1357 from doc-memory to master:

Try to thoroughly document unsafety of Memory and how it can be used
safely.

cc #1272

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:39):

alexcrichton merged PR #1357.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

Is it worth mentioning how this will change when we add threads?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

///     // Short-lived borrows of memory are safe, but they must be scoped and

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

grammaro: "There are" instead of "There's".

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

/// * Long-lived pointers are only valid if `Memory` isn't used in an unsafe way

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

It would make this example even more poignant if you don't pass a mem argument to some_other_function. The reference-counted nature of Memory means that there could be other unrelated paths to the Memory.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

///     // not valid because the slices overlap.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 19:41):

sunfishcode created PR Review Comment:

I suggest qualifying this in some way. If you never have a long-lived pointer into memory, you're probably good, but it's still good to be careful.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 21:15):

alexcrichton submitted PR Review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 18 2020 at 21:15):

alexcrichton created PR Review Comment:

Oh excellent point, I'll make a whole new section about this.


Last updated: Dec 23 2024 at 12:05 UTC