Stream: t-lang/wg-unsafe-code-guidelines

Topic: "allocated object"


RalfJ (Aug 04 2019 at 09:11, on Zulip):

Our offset/wrapping_offset docs talk about staying within the same "allocated object". That seems to confuse some people because "variables on the stack are not created by the allocator". Is there another term we could use? We want to include both stack- and heap-allocated variables.

RalfJ (Aug 04 2019 at 09:11, on Zulip):

Maybe we just have to be a bit more explicit, like "the same (stack- or heap-)allocated object"

rkruppe (Aug 04 2019 at 09:15, on Zulip):

I doubt there's any way to stop that misconception just by picking terminology cleverly, "stack and heap are radically different" is a widespread meme. How about explicitly saying something like: every variable "on the stack" is a separate allocation for this purpose

RalfJ (Aug 04 2019 at 09:53, on Zulip):

that sounds like a good idea

gnzlbg (Aug 05 2019 at 08:16, on Zulip):

every variable "on the stack" is a separate allocation for this purpose

In the abstract machine, every variable on the stack is a separate allocation, right?

gnzlbg (Aug 05 2019 at 08:17, on Zulip):

The stack and the heap aren't different here.

rkruppe (Aug 05 2019 at 08:22, on Zulip):

The whole point of this thread is that while they really aren't different for the abstract machine, this isn't clear to everyone.

gnzlbg (Aug 05 2019 at 09:04, on Zulip):

I'd just leave out the "for this purpose" out from the note.

gnzlbg (Aug 05 2019 at 09:06, on Zulip):

"Recall that every variable on the stack is a separate allocation in the abstract machine" might be enough

rkruppe (Aug 05 2019 at 09:14, on Zulip):

I don't expect everyone to know what "the abstract machine" is or what the implications of this clause are. I proposed adding "for this purpose" to dissuade e.g. arguments that "the entire stack is really just one big allocation in the kernel" by reminding people of the context (Rust-level UB), but I'm not overly attached to it.

gnzlbg (Aug 05 2019 at 10:25, on Zulip):

Maybe we can just say "Recall that in Rust every variable on the stack is a separate allocation" to avoid using the term abstract machine.

nagisa (Aug 05 2019 at 14:15, on Zulip):

the entire stack is really just one big allocation in the kernel

This already has a trivial counter-example in WASM

RalfJ (Aug 05 2019 at 16:56, on Zulip):

submitted a PR at https://github.com/rust-lang/rust/pull/63297

RalfJ (Aug 05 2019 at 16:56, on Zulip):

having to edit this in like 6 different places is so annoying :/

Last update: Nov 20 2019 at 13:15UTC