-
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
[release/7.0] Fix Interop.Gdi32.StartDoc p/invoke #76582
Conversation
Tagging subscribers to this area: @dotnet/area-system-drawing Issue DetailsBackport of #76569 to release/7.0 /cc @elinor-fung Customer ImpactTestingRiskIMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.
|
@elinor-fung, please check CI failures. |
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.
approved. we will take for consideration in 7 ga.
Did you consider adding a test that prints to PDF (similar to the original repro)? Worst case, we encounter some Windows SKU where drawing is supported but not print to PDF, and if that turns up we can just conditionalize the test. It seems worth such a test if it would catch something we'd take a fix this late for. |
Failures are unrelated: #74328, #76626 I looked into adding a test briefly. None of the existing tests actually try to use the normal print controller, so I thought adding one could result in chasing down intermittent test issues around conditioning based on machine environment. I'd rather not try to for 7.0, but can look into it more for main/8.0. |
sounds good, my suggestion would be to backport when it's proven stable in main (as printing is important to protect somehow) |
Approved by Tactics, signed off, and CI Failures investigated as unrelated. Ready to merge. |
Backport of #76569 to release/7.0
/cc @elinor-fung
Customer Impact
This is a customer-reported issue: #76538. An access violation occurs when trying to use
System.Drawing.Printing
APIs to print a document viaPrintDocument.Print
/StandardPrintController.OnStartPrint
. This is a regression from .NET 6 without a workaround.New in .NET 7 are source generated interop stubs. This p/invoke contained marshalling a sealed class, which previously would have been marshalled as a pointer to the native representation, but it regressed to marshaling as a copy (leading to the crash).
Testing
Validated using the customer-provided repro. No automated test was added. Automated test coverage of the printing APIs in
System.Drawing.Common
is limited - particularly when involving usage of OS APIs - due to the dependency on printers.Risk
Low. The fix is targeted to one p/invoke and one type that is used by that p/invoke only.