FractalFir / rustc_codegen_clr

This rust compiler backend(module) emmits valid CIL (.NET IR), enabling you to use Rust in .NET projects.
MIT License
1.56k stars 35 forks source link

Incorrect handling of getting the address of an unsized place #28

Closed FractalFir closed 9 months ago

FractalFir commented 11 months ago

The code handling places currently incorrectly assumes only slices and string slices are unsized.

There are other types which are unsized(e.g. Path).

This is the cause of a miscompilation preventing the .NET build of std from opening files.

This MIR statement:

_7 = &(((*_1).0: ffi::os_str::OsStr).0: sys::unix::os_str::Slice)

attempts to convert a path to the underlying slice. Due to this bug, the codegen emits code which sets the proper slice address, but not size. This causes std to attempt to allocate an incorrectly sized buffer(~17TB), which fails.