-
Notifications
You must be signed in to change notification settings - Fork 676
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
C# Debugger does not understand DateTime #753
Comments
@jchannon thanks for the report! Good bug. Here is a slightly simpler repro: public class Program
{
public static DateTime ReturnInput(DateTime input)
{
return input;
}
public static void Main(string[] args)
{
DateTime now = DateTime.Now;
Console.WriteLine(now); // set breakpoint here
}
}
Result: Expected: |
@mikem8361 I am guessing (though I don't have anything to back this up other than this seems similar to the previous bug with decimal) that this is a runtime bug with marshalling large struct input arguments. Would you mind trying this (or emailing me instructions on how we can try this) with mdbg? |
One thing it emphasise is if you look in the variable window the DateTime is in US format but when you expand the DateTime object it's shown in UK locale (where I am located) so it shows 09/08/2016 10:54:18 but then expanded shows that the Date property is 08/09/2016 |
@jchannon I don't think this matters - the issue is that when we pass the DateTime as an input argument to a function (subtraction operator in your example) the value is being corrupted as it passed to the function. |
Maybe we have 2 issues here On Thursday, 8 September 2016, Gregg Miskelly [email protected]
|
The bug was with any 16 byte value type. The mdbg syntax is awkward something like "funceval namespace.class.get_Value instance". Sent from my Verizon, Samsung Galaxy smartphone -------- Original message -------- Maybe we have 2 issues here On Thursday, 8 September 2016, Gregg Miskelly [email protected]
You are receiving this because you were mentioned. |
@mikem8361 would the bug apply non-this input arguments? |
No, only return values. On Linux and OS X, the calling convention has 16 byte values being returned in RCX:RDX unlike windows where a return value pointer is passed to method. The funceval code wasn’t dealing with that case even though the runtime did. mikem From: Gregg Miskelly [mailto:[email protected]] @mikem8361https://github.com/mikem8361 would the bug apply non-this input arguments? — |
@mikem8361 Yes, that is what I thought. I think this might be a new bug that affects input arguments of large structs. Its possible that it is VIL that is somehow setting up the func eval wrong, but this works correctly on Windows, and this isn't specific to DateTime -- I see the same issue if I make my own 16-byte struct. |
@jkotas do we pass in 16 bytes into a method in registers on Linux/OS X like return values? From: Gregg Miskelly [mailto:[email protected]] @mikem8361https://github.com/mikem8361 Yes, that is what I thought. I think this might be a new bug that affects input arguments of large structs. Its possible that it is VIL that is somehow setting up the func eval wrong, but this works correctly on Windows, and this isn't specific to DateTime -- I see the same issue if I make my own 16-byte struct. — |
Correct. |
Is the ENREGISTERED_PARAMTYPE_MAXSIZE the correct define? It seems to be 8 bytes on all x64 platforms (16 bytes on ARM64). From vm\amd64\cgencpu.h: #define ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE 8 // bytes #ifdef UNIX_AMD64_ABI From: Jan Kotas [mailto:[email protected]] @jkotashttps://github.com/jkotas do we pass in 16 bytes into a method in registers on Linux/OS X like return values? Correct. — |
The code for this is under |
Looks like the bug repros under mdbg. [p#:0, t#:0] mdbg> print now |
@mikem8361 - the ENREGISTERED_PARAMTYPE_MAXSIZE is defined as 16 for UNIX_AMD64_ABI (you may have misread it as ARM64) |
@mikem8361 Ah, sorry, that was the ENREGISTERED_RETURNTYPE_MAXSIZE. The ENREGISTERED_PARAMTYPE_MAXSIZE is set to 8 which is wrong, the return and param sizes the same. |
@mikem8361 Interesting - the value was always wrong - never updated since the initial commit. |
The same issue is for ENREGISTERED_RETURNTYPE_INTEGER_MAXSIZE. That should also be 16 for Unix AMD64. That one influences two places. One in the arg iterator the case when the parameter is typedbyref when it would incorrectly set flag indicating that a return buffer is needed for structs over 8 bytes. And the other in IsUnmanagedValueTypeReturnedByRef which is used by marshalling. |
Let me fix the constants, I'll send a PR in a minute. |
Cool. I created https://github.com/dotnet/coreclr/issues/7115 to track this. I will resolve this as External. |
@gregg-miskelly - I am not sure if fixing the constants will fix the problem in the debugger. So maybe it would be better to leave this open and close it after it is verified that it has fixed the issue. The point is that the structs of upto 16 bytes in registers are passed correctly at most places as parameters, we have a test for that in CoreCLR. |
@janvorli Its possible that there will be other CoreCLR bugs too, but since Mike found this repos in mdbg, I am pretty sure that all the issues are on the CoreCLR side. So I would suggest we leave https://github.com/dotnet/coreclr/issues/7115 open until we have verified the fix in mdbg. |
@jchannon for the weird switching between US date time format (mm/dd/yyyy) and UK, do you get the same behavior if you just evaluate the functions normally? In other words, try adding this code: string lastmodifiedStr = lastmodified.ToString();
string lastmodifiedDateStr = lastmodified.Date.ToString(); And evaluate those strings under the debugger. |
Adding that code and looking in the Variables window the string representation is the UK format. |
The two known bugs in CoreCLR that were effecting this scenario are now set to be fixed for .NET Core 1.1. |
Is that Q1 2017? On Thursday, 15 September 2016, Gregg Miskelly [email protected]
|
Fall 2016 according to https://github.com/dotnet/core/blob/master/roadmap.md#ship-dates |
Aha. Thanks On Thursday, 15 September 2016, Gregg Miskelly [email protected]
|
Hi, just installed netcore 1.1 and this doesn't seem to be fixed I ran the same repro as suggested by @gregg-miskelly here #753 (comment) This is also visible in Jetbrains Rider |
@jchannon unfortunately @mikem8361 said that https://github.com/dotnet/coreclr/issues/7115 didn't actually make 1.1. @mikem8361 can @jchannon install a preview3 CLI to check if this repos? Or will preview3 also be missing the fix? |
The milestones on the issue/PR says 1.1 so you might want to change that, On 17 November 2016 at 16:32, Gregg Miskelly [email protected]
|
Agreed :) |
I’m not sure if the fix is in the dotnet cli review3 (I don’t know how to figure that out), but if you add "Microsoft.NETCore.Runtime.CoreCLR": "1.2.0-beta-24609-02" to your test app’s project.json it will have the fix. |
Environment data
dotnet --info
output:VS Code version:1.4.0
C# Extension version:1.4.1
Steps to reproduce
Debug a C# app and look at a DateTime object in Variables/Debug Console window
Expected behavior
To show a DateTime object at correct locale and when in Debug Console doing something like
(dateA - dateB).TotalSeconds
to show correct resultsActual behavior
The text was updated successfully, but these errors were encountered: