dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.01k stars 4.67k forks source link

`GenTreeAddrMode` has implicit truncation for its `gtOffset` field #86609

Open tannergooding opened 1 year ago

tannergooding commented 1 year ago

The constructor takes in and stores a ssize_t offset: https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gentree.h#L7089

However, it returns an int Offset() which may result in implicit truncation and loss of data: https://github.com/dotnet/runtime/pull/86400

We should likely change the signature to take in an int and ensure that all taken offsets are in range.

ghost commented 1 year ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.

Issue Details
The constructor takes in and stores a `ssize_t offset`: https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/gentree.h#L7089 However, it returns an `int Offset()` which may result in implicit truncation and loss of data: https://github.com/dotnet/runtime/pull/86400 We should likely change the signature to take in an `int` and ensure that all taken offsets are in range.
Author: tannergooding
Assignees: -
Labels: `area-CodeGen-coreclr`, `untriaged`
Milestone: -