-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cdac] Physical contract descriptor spec #100365
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good direction, but I have a few comments.
f37c8a8
to
4bd9a58
Compare
4bd9a58
to
77afeac
Compare
the issue is that we can't dereference pointers until we know the target endianness and pointer size. which we can only discover by reading the actual descriptor magic and flags
if there are multiple hosted runtimes, diagnostic tooling should look in each loaded module to discover the contract descriptor
uint32_t aux_data_count; | ||
uint32_t descriptor_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put the count/size right before or after the descriptor/aux_data instead?
|
||
To aid in the discovery the contract descriptor should be exported by the module hosting the .NET | ||
runtime with the name `DotNetRuntimeContractDescriptor`. (Using the C symbol conventions of the | ||
target platform. That is, on platforms where such symbols typically have an `_` prepended, this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are those platforms?
FWIW, the existing DotNetRuntimeDebugHeader
seems to be exported without _
everywhere:
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Lines 245 to 246 in ab2bd48
<IlcArg Condition="'$(_targetOS)' == 'win' and '$(DebuggerSupport)' != 'false'" Include="--export-dynamic-symbol:DotNetRuntimeDebugHeader,DATA" /> | |
<IlcArg Condition="'$(_targetOS)' != 'win' and '$(DebuggerSupport)' != 'false'" Include="--export-dynamic-symbol:DotNetRuntimeDebugHeader" /> |
If `ptrSize` is 0, the architecture is 64-bit. If it is 1, the architecture is 32-bit. The | ||
reserved bits should be written as zero. Diagnostic tooling may ignore non-zero reserved bits. | ||
|
||
The `descriptor` is a pointer to a JSON string described in [data descriptor physical layout](./data_descriptor.md#Physical_JSON_descriptor). The total length (including nul terminator character) is given by `descriptor_size`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would omit the terminating null in the descriptor_size
.
The data contract reader cannot assume that the descriptor is null terminated. It needs to be robust against malicious input. Including the terminating null does not seem to be beneficial, it just adds extra logic to the reader to verify that there is a null at the end and strip it.
Co-authored-by: Elinor Fung <[email protected]>
- put the aux data and descriptor sizes closer to the pointers - Don't include trailing nul `descriptor_size`. Clarify it is counting bytes and that `descriptor` is in UTF-8 - Simplify `DotNetRuntimeContractDescriptor` naming discussion
Building on dotnet#100253 , describe an in-memory representation of the toplevel contract descriptor, comprisied of: * some target architecture properties * a data descriptor * a collection of compatible contracts Contributes to dotnet#99298 Fixes dotnet#99299 --- * [cdac] Physical contract descriptor spec * Add "contracts" to the data descriptor * one runtime per module if there are multiple hosted runtimes, diagnostic tooling should look in each loaded module to discover the contract descriptor * Apply suggestions from code review * Review feedback - put the aux data and descriptor sizes closer to the pointers - Don't include trailing nul `descriptor_size`. Clarify it is counting bytes and that `descriptor` is in UTF-8 - Simplify `DotNetRuntimeContractDescriptor` naming discussion --------- Co-authored-by: Elinor Fung <[email protected]>
Building on #100253 , describe an in-memory representation of the toplevel contract descriptor, comprisied of:
Contributes to #99298
Fixes #99299