oxidecomputer / oxidecomputer/usdt

Justification around `nomem` specifier

Open
#494 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
145
Forks
15
Avg merge
14m
Merged PRs (30d)
6

Description

This crate specifies nomem in the asm!(), and casts pointers to usize.

https://github.com/oxidecomputer/usdt/blob/4329591597b3ceaab78d606cf601781c6a99e6de/usdt-impl/src/no-linker.rs#L112

https://github.com/oxidecomputer/usdt/blob/4329591597b3ceaab78d606cf601781c6a99e6de/usdt-impl/src/common.rs#L182


The inline assembly docs specify

The assembly code does not read from or write to any memory accessible outside of the assembly code. This allows the compiler to cache the values of modified global variables in registers across execution of the assembly code since it knows that they are not read from or written to by it.

It's quite clear that reading from a pointer value when nomem is set is UB. The probe function would necessarily need to read the pointer when tracing.

Wouldn't it be more appropriate to use readonly?

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the asm!() usage in usdt-impl/src/no-linker.rs:112 and the pointer cast in usdt-impl/src/common.rs:182, then read Rust’s documented nomem and readonly options. Trace the probe path to determine whether the assembly accesses the pointed-to memory. Done means the selected option is technically correct and the rationale is documented in the issue or code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.