Skip to content
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

Remove unsafe code from number parsing #10397

Open
Tracked by #94941
danmoseley opened this issue May 29, 2018 · 11 comments
Open
Tracked by #94941

Remove unsafe code from number parsing #10397

danmoseley opened this issue May 29, 2018 · 11 comments
Labels
area-System.Numerics Cost:M Work that requires one engineer up to 2 weeks help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@danmoseley
Copy link
Member

danmoseley commented May 29, 2018

There is heavy use of unsafe code in number.parsing.cs and calling code (eg at

private static unsafe bool TryParseNumber(ref char* str, char* strEnd, NumberStyles styles, ref NumberBuffer number, NumberFormatInfo info)
). This could be rewritten with ReadOnlySpan<char> to eliminate the char * resulting in safer code that is also easier to read.

Relates to dotnet/coreclr#17808

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 26, 2020
@tannergooding tannergooding added area-System.Numerics and removed area-System.Runtime untriaged New issue has not been triaged by the area owner labels Jun 23, 2020
@ghost
Copy link

ghost commented Jun 23, 2020

Tagging subscribers to this area: @tannergooding
Notify danmosemsft if you want to be subscribed.

@tannergooding tannergooding added the help wanted [up-for-grabs] Good issue for external contributors label Jun 23, 2020
@felipepessoto
Copy link
Contributor

felipepessoto commented Jul 2, 2020

@danmosemsft, @tannergooding, do you know a better strategy to edit/build/test it?

I was running these two command, but the first one takes a long time to run:

.\build.cmd -subset clr+libs -c Checked /p:BuildNative=false
D:\Repos\runtime\src\libraries\System.Runtime\tests> dotnet build /t:Test /p:Configuration=Checked

So, I'm currently doing this:

.\build.cmd -subset clr -c Checked /p:BuildNative=false

Copy "D:\Repos\runtime\artifacts\bin\coreclr\Windows_NT.x64.Checked\System.Private.CoreLib.dll"
To D:\Repos\runtime\artifacts\bin\testhost\net5.0-Windows_NT-Checked-x64\shared\Microsoft.NETCore.App\5.0.0\

D:\Repos\runtime\src\libraries\System.Runtime\tests> dotnet build /t:Test /p:Configuration=Checked

@danmoseley
Copy link
Member Author

You're changing src/libraries/System.Private.CoreLib/src/System/Number.Parsing.cs and src/libraries/System.Runtime/tests right? @safern didn't we recently change things so that building src\libraries\System.Runtime\tests would also build System.Private.Corelib? In that case I would expect you could build clr+libs just once, and then iterate by doing dotnet build /t:build;test on System.Runtime\tests. Would that be right?

@safern
Copy link
Member

safern commented Jul 2, 2020

Yeah we did but that doesn’t update the testhost because System.Private.CoreLib configuration has to match the whole runtime. What I do when I change System.Private.CoreLib and want to iterate on it to test again I run:

build.cmd clr.corelib+clr.nativecorelib+libs.pretest -rc <RuntimeConfig>

that will build Corelib, will run cross gen in it and will bin place it in the testhost.

@danmoseley
Copy link
Member Author

@felipepessoto does that work for you?

I would not have figured that out. I wonder whether this is worth adding as an example to build -? and also documenting in docs/workflow/building/libraries/README.md. It's always good when we couch docs/help in terms of "if you want to do common thing X, then use this command line Y".

@felipepessoto
Copy link
Contributor

I'll try it.
@safern, do you also know the easiest way to debug System.Private.CoreLib? Like the Number class

@safern
Copy link
Member

safern commented Jul 2, 2020

I wonder whether this is worth adding as an example to build -? and also documenting in docs/workflow/building/libraries/README.md

Yeah makes sense, I'll add it.

I'll try it.
@safern, do you also know the easiest way to debug System.Private.CoreLib? Like the Number class

I usually just use the VS Test explorer and set breakpoints in System.Private.CoreLib source code

@felipepessoto
Copy link
Contributor

@felipepessoto does that work for you?

I would not have figured that out. I wonder whether this is worth adding as an example to build -? and also documenting in docs/workflow/building/libraries/README.md. It's always good when we couch docs/help in terms of "if you want to do common thing X, then use this command line Y".

Worked very well. Now it takes 30~60 seconds to compile, much better than 12 minutes. Thanks.

@safern
Copy link
Member

safern commented Jul 2, 2020

Worked very well. Now it takes 30~60

Btw, if you pass down the -build action to the script it will be faster since it will not do any of the -restore routines. i.e:

build.cmd clr.corelib+clr.nativecorelib+libs.pretest -build -rc <RuntimeConfig>

@danmoseley
Copy link
Member Author

Shouldn't restore be super fast now, if it's already run?

@safern
Copy link
Member

safern commented Jul 2, 2020

Shouldn't restore be super fast now, if it's already run?

It is, but in this case since you're using build.cmd it takes a few seconds to run the global tools install that arcade does for Tools.props etc, so it saves some seconds.

@tannergooding tannergooding added the Cost:M Work that requires one engineer up to 2 weeks label Jan 15, 2021
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 14, 2021
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 24, 2021
@EgorBo EgorBo mentioned this issue Jan 13, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Numerics Cost:M Work that requires one engineer up to 2 weeks help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants