Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Sep 15, 2021

Backport of #59096 to release/6.0

/cc @ericstj

Fixes #58741

Customer Impact

Regression from .NETFramework and .NETCore causing a unexpected ExternalException related to session transitions (sleep/wake, Remote Desktop, etc)

Testing

Manually verified in debugger. Unit tests.

Risk

Very low. Adds back SetLastError to only those PINvokes which require it.

System.Drawing uses the last Win32 error in CheckErrorStatus to try to
guess at why a GdiPlus draw method failed and ignore some failures.

This was broken in .NETCore when SetLastError was removed from PINvokes.

Bring back SetLastError for all PInvokes that use CheckErrorStatus.
@ghost ghost added the area-System.Drawing label Sep 15, 2021
@ghost
Copy link

ghost commented Sep 15, 2021

Tagging subscribers to this area: @safern, @tarekgh
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #59096 to release/6.0

/cc @ericstj

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Drawing

Milestone: -

@ericstj ericstj requested a review from JeremyKuhne September 15, 2021 13:08
@danmoseley danmoseley added the Servicing-approved Approved for servicing release label Sep 15, 2021
@danmoseley
Copy link
Member

Approved. Customer reported. Break introduced since last version. Relatively low risk. Would likely meet servicing bar.

@AaronRobinsonMSFT maybe this discussion already happened, but does this suggest similar breaks may occur in pinvokes in customers code due to the original change?

@danmoseley danmoseley closed this Sep 15, 2021
@danmoseley
Copy link
Member

restarting with wasm publish fix.

@danmoseley danmoseley reopened this Sep 15, 2021
@danmoseley
Copy link
Member

@dotnet/dnceng I reopened the PR to pick up another change and restart validation and lots of legs canceled themselves. I can't see info on Azdo about them. What happened and how do I get them to run?

@danmoseley
Copy link
Member

@dotnet/dnceng more mysterious cancellations.

@lukas-lansky
Copy link
Contributor

Interesting! @ChadNedzlek, do you have an idea what might be the problem here?

@MattGal
Copy link
Member

MattGal commented Sep 15, 2021

@dotnet/dnceng more mysterious cancellations.

Can you link the pipeline that did this? When I click through or look at everything for 59151 in AzDO I see one actively running job.

@AaronRobinsonMSFT
Copy link
Member

AaronRobinsonMSFT commented Sep 15, 2021

@AaronRobinsonMSFT maybe this discussion already happened, but does this suggest similar breaks may occur in pinvokes in customers code due to the original change?

As in, if customers were using these P/Invokes directly? I don't think that is possible because they are marked internal but if we have small wrappers around them without calls to Marshal.GetLastWin32Error() then it is definitely possible. In this case though we became too permissive not overly restrictive. By that I mean we made the call and perhaps it errored out in a way we didn't throw an exception where we used to. If users did change their code it was likely to revert to being more restrictive again so they could have added their own Marshal.GetLastWin32Error(). If this was done there is now an inefficiency in user code but nothing else.

I could also be missing what you are asking.

@danmoseley
Copy link
Member

@AaronRobinsonMSFT ah, I likely misunderstood the original thread. If indeed this was simply a latent bug in Drawing unrelated to any 6.0 Interop changes, then my question does not apply.

@ericstj
Copy link
Member

ericstj commented Sep 15, 2021

Yeah, this bug exists in 3.1 and 5.0 as well (and folks have suggested we patch it there as well).

@Anipik Anipik merged commit 18794fa into release/6.0 Sep 15, 2021
@danmoseley danmoseley deleted the backport/pr-59096-to-release/6.0 branch September 15, 2021 19:09
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Drawing Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants