Skip to content

const attribute of an instance of host_interface is ignored #73402

@RobertHenry6bev

Description

@RobertHenry6bev

Description

using tag v7.0.0-preview.6.22324.4

Consider this line: https://github.com/dotnet/runtime/blob/main/src/native/corehost/fxr/fx_muxer.cpp#L143

which establishes a const reference top a host_interface_t

However, the current libhostpolicy_contract has its load function bound to function corehost_load(host_interface_t*). This is to say that the corehost_load function is declared to take a non const pointer, but we passed in an address of a const host_interface_t

I wonder if corehost_load scribbles on its non-const argument, to the detriment of the caller

print hostpolicy_con
$5 = {
  load = 0x7ffff6eb77b0 <corehost_load(host_interface_t*)>,
  unload = 0x7ffff6ebbd20 <corehost_unload()>,
  set_error_writer = 0x7ffff6ebcf70 <corehost_set_error_writer(corehost_error_writer_fn)>,
  initialize = 0x7ffff6eb9cb0 <corehost_initialize(corehost_initialize_request_t const*, uint32_t, corehost_context_contract*)>,
  corehost_main = 0x7ffff6eb8670 <corehost_main(int, pal::char_t const**)>,
  corehost_main_with_output_buffer = 0x7ffff6eb96e0 <corehost_main_with_output_buffer(int, pal::char_t const**, pal::char_t*, int32_t, int32_t*)>
}

Reproduction Steps

Compile the runtime with clang-14 -fsanitize=undefined and then run and wait to see this type mismatch discovered at run time.

Expected behavior

we see a runtime error

Actual behavior

ubsan runtime declares a runtime error

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

/cc @aaronrobin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions