Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Remove empty try's #13493

Merged
merged 3 commits into from
Aug 22, 2017
Merged

Remove empty try's #13493

merged 3 commits into from
Aug 22, 2017

Conversation

danmoseley
Copy link
Member

Just remove cases where we still had empty try's.

This isn't very interesting, but what is the status of CER's in CoreCLR? What does RuntimeHelpers.PrepareConstrainedRegions(); do? Is there cleanup possible?

// Windows NT 3.5 and later the timer resolution is approximately 10ms,
// for Windows NT 3.1 it is approximately 16ms, and for Windows 95 and 98
// it is approximately 55ms.
// Windows NT 3.5 and later the timer resolution is approximately 10ms.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And 10ms is out of date - see #9736

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, you fixed it while I was searching for that PR :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I dug up exactly that PR :)

@janvorli
Copy link
Member

@danmosemsft why are we removing the empty trys? Isn't the thread abort protection still needed in those regions? Funceval in VS uses thread abort to abort evaluation of functions that took too long time to execute and the changes you've made would seem to lead to leaks in case the abort happens in the region that were protected by the finally blocks with empty try before.

@danmoseley
Copy link
Member Author

My understanding was thread abort was no longer supported. There was a jit change recently that elided empty trys. Sounds like I misunderstood, or corefx is different?
Cc @jkotas

@jkotas
Copy link
Member

jkotas commented Aug 21, 2017

Thread abort in .NET Core is used for the limited func eval case only. The runtime and framework are not built and tested to be fully reliable in the presence of thread aborts.

@danmoseley
Copy link
Member Author

Was that broken by 119b04c ?

@danmoseley danmoseley added the * NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 21, 2017
@AndyAyersMS
Copy link
Member

From the jit side, finally cloning also has a similar effect -- finally clauses are cloned to streamline the non-exception path performance and the clones are not reported as finallys to the runtime (see #8551).

@danmoseley
Copy link
Member Author

@AndyAyersMS can you clarify, do you mean that 119b04c means that empty try clauses are never seen by the runtime anyway?

@AndyAyersMS
Copy link
Member

Not quite, just that empty try removal and finally cloning have similar impact on the way that the code originally within the finally clause is reported to the runtime.

Finally cloning is more general and has more widespread impact and also came first, so it is the main culprit in the behavior change.

@danmoseley
Copy link
Member Author

OK I'm still confused. Specifically: does the empty try pattern, used in the desktop framework to indicate code that must run on thread abort, similarly functional on .NET Core? If it's not, it sounds like that may surprise @janvorli / @jkotas who expect it to be.

@AndyAyersMS
Copy link
Member

On .Net Core, when the jit optimizes the code, then protection against thread abort is no longer guaranteed for code in finally clauses. Whether the try is empty or not empty does not matter.

If the jit is not optimizing the code, what happens to code in finally clauses during thread abort is up to the runtime.

@danmoseley
Copy link
Member Author

OK. Given this @janvorli / @jkotas would you prefer I leave the try's as they are, or remove them ?

@jkotas
Copy link
Member

jkotas commented Aug 22, 2017

I do not see a problem with removing them. There are hundreds of places that are not robust against thread abort. Having a few more won't make a difference. We are not building .NET Core to be fully reliable in the presence of thread abort.

@danmoseley danmoseley merged commit 4699409 into dotnet:master Aug 22, 2017
@danmoseley danmoseley deleted the cleanup.trys branch August 22, 2017 05:25
@karelz karelz modified the milestone: 2.1.0 Aug 28, 2017
dotnet-bot pushed a commit to dotnet/corert that referenced this pull request Sep 7, 2017
* Remove empty try's

* Remove some dead comments

* more

Signed-off-by: dotnet-bot <[email protected]>
jkotas pushed a commit to dotnet/corert that referenced this pull request Sep 7, 2017
* Remove empty try's

* Remove some dead comments

* more

Signed-off-by: dotnet-bot <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
* NO MERGE * The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants