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

CreateActCtx is returning the wrong SafeHandle #1581

Closed
ptsoccer opened this issue May 17, 2023 · 3 comments · Fixed by microsoft/CsWin32#941
Closed

CreateActCtx is returning the wrong SafeHandle #1581

ptsoccer opened this issue May 17, 2023 · 3 comments · Fixed by microsoft/CsWin32#941
Assignees
Labels
bug Something isn't working

Comments

@ptsoccer
Copy link

Actual behavior

I am running into an issue with https://github.com/ookii-dialogs/ookii-dialogs-wpf where upon closing the program, I get an SEHException on disposal of a SafeFileHandle. The HRESULT is 8000 4005 (unspecified error). I believe this is because CreateActCtx is returning a SafeFileHandle and thus CloseHandle is being called on the ctx rather than ReleaseActCtx.

Expected behavior

The handle returned by CreateActCtx should close the handle with ReleaseActCtx

Repro steps

This code, in a WPF or winforms app, along with version 5.0.1 of Ookii.Dialogs.Wpf should cause the error. I don't need it disabled, but disabling "Just my code" might also be necessary.

using (var taskDialog = new TaskDialog()
                   {
                       Buttons =
                       {
                           new TaskDialogButton(ButtonType.Ok),
                       }
                   })
            {
                taskDialog.ShowDialog();
                Close();
            }

Context

@ptsoccer ptsoccer added the bug Something isn't working label May 17, 2023
@AArnott
Copy link
Member

AArnott commented May 19, 2023

Thanks for your report. This needs to be fixed in the metadata.

@AArnott AArnott transferred this issue from microsoft/CsWin32 May 19, 2023
@mikebattista
Copy link
Collaborator

mikebattista commented May 19, 2023

We are discussing changing how RAIIFree is handled in #1575.

In that world, CreateActCtx would return HANDLE like today but would have return: RAIIFree("ReleaseActCtx") on it to override the default RAIIFree function on HANDLE (CloseHandle).

@AArnott what do you think of this change? Would you be able to address this issue with that design?

@mikebattista mikebattista self-assigned this May 19, 2023
@AArnott
Copy link
Member

AArnott commented May 19, 2023

Yes, I can make cswin32 work with that.

AArnott added a commit to microsoft/CsWin32 that referenced this issue May 24, 2023
Some APIs return a common handle type but require the handle to be released with a less-common method. The metadata now includes this detail, and with this change, CsWin32 honors that.

Fixes microsoft/win32metadata#1581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants